Gas in the stomach and intestines is something that everyone has. The gas consists of air that you swallow or that forms in the large intestine when the body breaks down food. Having gases can cause your stomach to swell and cause you pain, but is usually not dangerous and is rarely due to a serious illness.
When you have lactose intolerance you have a reduced ability to absorb lactose, ie milk sugar from the food. This is because the intestinal mucosa has a lower level of an enzyme, lactate, which is required for the milk sugar to be broken down and taken up by the small intestine. With a lowered level of lactase, milk sugar will instead end up in the large intestine and will be broken down by bacteria, which can cause pain, diarrhea and gas formation.