Pain under the left rib front and back only wen I sit certain ways and it's not there all the time, wot could it be?

Doctor should check. On the left side are the stomach, spleen, diaphragm (muscle for breathing), ribs, a part of the colon (large intestine), the tail end of the pancreas, etc... Pain can be from the ribs and their cartilage, a swollen spleen, stomach acidity/gastritis/reflux, muscle strains in the abdominal muscles or diaphragm, excess stool or gas in the colon, pancreatitis, a cancerous tumor, etc....