Pinched muscles in your back are causing that pain. That they are happening more often indicates that the muscles are getting tighter so it's easier to happen. When you make certain movements it causes the tight muscles to get bound up so they shoot off some pain and when the pressure is off the pinched are it can go back to a pain free state. When you have pinched muscles in your back the pain often follows the nerves to show up as pains in the front and sides. To get rid of the problem so it doesn't happen again you have to free up the muscles in your back and here's how to do that:
Back:
(do from a sitting position)
Place your left hand on your left leg next to your body. Place your right hand over your left shoulder, fingers over the back and the palm in the front and firmly press on them and hold. After 30 seconds slowly lower your body forward and to the outside of your left leg, keeping your left arm fairly straight as you do. When you reach your lap remain there for another 10 seconds, release the pressure but rest there for another 30 seconds. Then reverse your hand positions and do your right side.
For best results relax your body first by taking a deep breath and exhaling then remain this relaxed.