Pain this sudden and severe on both sides of your back ribs can come from a muscle spasm, costochondritis, or a flare of gas and acidity, as you suspected. The fact that it does not worsen with breathing is reassuring against a lung cause. But pain this severe still deserves an in-person check rather than guessing. A warm compress and rest can help if it turns out to be muscular.
Health Tips
See a physician in the next day or so for an exam. Go to urgent care now if the pain worsens, spreads to your chest or arm, or comes with fever or breathlessness.