Anaerobic bacteria are the culprits behind nearly all forms of bad breath. They are micro-organisms which require an oxygen-free environment. The word "anaerobic" means "without air", and for our purposes, air is synonymous with oxygen. The human mouth provides an ideal environment in which these organisms can flourish.
So why the mouth?
Well, for starters, the tongue's surface is covered with fibrous growths called papillae. Oxygen rarely penetrates to where these fibers join the main body of the tongue, which allows these microbes to live and reproduce successfully. They also do well deep in the throat, in tonsillar crypts, and in the sinuses.
Another reason for their presence in the mouth is that these organisms play an important role in the digestive process. Their job is to break down proteins found in specific foods. And they do it quite effectively. The downside, however, is that proteins are also found in oral and sinus secretions which find their way to the tongue and back of the throat as well as in blood and diseased oral tissue. Unable to differentiate between protein sources, they feed on proteins from these sources as well.
The breakdown process produces a number of compounds such as Hydrogen Sulfide and Methyl Mercaptan, which are loaded with sulfur. The breakdown of these compounds creates unpleasant odors and tastes. When the bacteria break down proteins at a normal rate, everything's fine. Your breath remains fresh or is at least manageable. From time to time, however, conditions occur which cause the bacteria to process proteins more rapidly or which cause the bacteria to reproduce more quickly. When this occurs, bad breath is the result.