Gas formation in the stomach happens when we swallow air while eating or drinking. This gas is expelled out either from the mouth or from the anus. Sometimes there is difficulty in passing the gas or if the gas gets trapped abdominal pain or bloating is experienced.