While some of the bacteria can be harmful, most are not and some are even helpful. Certain types of bacteria, however, can attach themselves to hard surfaces like the enamel that covers your teeth. If they're not removed, they multiply and grow in number until a colony forms. More bacteria of different types attach to the colony already growing on the tooth enamel. This film is called plaque, and it's what causes cavities.
Sugar plays a harmful role in tooth decay.
The bacteria that form together to become plaque, use sugar as a form of energy. They multiply faster and the plaque grows in size and thickness. Some of the bacteria turn the sugar into a kind of glue that they use to stick themselves to the tooth surface. This makes it harder for the bacteria to get washed away with your saliva. The hard, outside covering of your teeth is called enamel.