Farts can be blamed on oligosaccharides or, if you prefer, the dog.
Beans, like other fibrous foods, soybeans, cabbage, peas, cauliflower, are made up of a special kind of sugar called oligosaccharides.
These sugar molecules are very large and are not digested by the small intestine, so they pass on, more or less whole, to the large intestine, where colonies of bacteria lie in wait.
The bacteria absolutely adore these large sugar molecules and multiply like rabbits, releasing gases as they go.
With no place to go but down, the gases invariably reach your colon the moment you step onto an elevator or meet your new boss.