There are two solutions to avoid a bacterial invasion: having no bacteria in the first place or killing them when they show up. Or both.

So it is necessary to take great care of the cleanliness of the material to be used. Do not touch sensitive parts of the material (bottom of rubber stopper, inside of carboy and bottle necks, etc.) with fingers. Keep contact with air to a minimum to prevent bacteria from entering.

Conditions hostile to bacteria must also be maintained:

These conditions are unfavorable for yeasts as well but yeasts have been selected if not trained to withstand them. Wine yeasts can tolerate an alcohol content around 15 % (30 proof) but -- most -- bacteria cannot live when there is more than 2-4 % alcohol. Beer (8-10 proof) keeps for a few months, wine (125 proof) for years and brandies  (80+ proof) forever. A vigorous fermentation produces alcohol quickly and within a few days the must becomes inhospitable for bacteria.

May 28th 2002