As someone who has dealt with this basically their entire life, there really doesn't seem to be a one size fits all for this problem. And after doing extensive research (googling lol), it seems like the medical/sports community also doesn't have a universal understanding of it either.
Some people say it's lactic acid, some say it's shallow breathing/not using diaphragmatic breathing, some say it's eating/drinking too close to a race, some say it's muscle spasms, some say it's running posture, etc. I have had instances where they've occurred where it seemed it could be any of the above reasons. The people who say it only happens to inexperienced runners is wrong. Look what happened to Kincaid last year.
In high school I really had zero knowledge about running, and apparently so did my coach. Regardless, I would go out way too hard in every XC race and get hit with a major side stitch by the halfway mark, almost fully incapacitating me.
Having since improved my high school times by quite a large amount and learning to pace myself better, I still occasionally get side stitches. They either happen on my right rib cage or my right shoulder, and it seems to happen moreso when I am running downhill. I usually try the forcefully expelling air when taking a right step trick, and not sure if coincidental, but typically works itself out after a few minutes. I just don't let it affect me the way I used to. Mind you they are much less debilitating than they were in high school, but it's definitely frustrating.
I've really tried to be more rhythmic with my breathing, but I find it really hard to do so. So therefore I just try to make sure I take deeper breaths through my belly and not just quick, shallow breaths in my chest. If someone has a super specific rhythmic breathing that works for them let me know, but I seem to struggle with staying focused on it.