Usually naturally produced in saliva and the stomach, these can be on the low side. If so, food then passes from the stomach into the gut partially undigested, making it more likely to ferment which in turn results in bloating. Try taking a digestive enzyme supplement – look for one with hydrochloric acid in it (listed as HcL) – but only ever take it with main meals and never on an empty stomach. (NB If you have acid reflux, take one without Hcl in it.)
Beneficial bacteria live in the gut in their billions, and have several roles from helping the body use minerals to making B vitamins. They are also partially responsible for the last stage of digestion and if their numbers are sufficient, they fill the gut so that any unwanted bacteria doesn’t get a chance to thrive. While we are all exposed to the less good bacteria and yeasts, in a healthy gut they are dealt with speedily and quite routinely. However, if you don’t have enough of the good stuff (that’s Lactobacillus and Bifidobacterium) then the bad stuff has a chance to multiply. And when they do, they can produce gas which contributes to flatulence and bloating.