Another way of describing cavities is tooth decay. Tooth decay is almost entirely caused by the buildup of a bacterial film called plaque.
The many types of bacteria in your mouth are what initiate plaque accumulation. When the bacteria the sugars from the foods we eat interact, they begin to produce acids.
These acids that are produced then break down the protective layer around your teeth called enamel. Cavities will start to form where the enamel is weakest.
Fuente: Youtube/Gross Science