Your saliva contains various bacteria that attach themselves to your teeth. These bacteria love to eat sugar, and every time you put something sweet in your mouth they make sure they eat some of that sugar.
From this sugar the bacteria create both a strong acid and a kind of glue that makes them stick even more firmly to the tooth. Eventually they form small coherent deposits, plaque.
The acid that is formed eats away at the tooth, creating microscopically small holes. A defence system in the saliva, however, immediately starts to counteract this acid formation. It takes the saliva around 30 minutes to neutralise the acid. Then the saliva, which also contains calcium, starts to repair the damage done by the acid.
This repair work takes around two hours. Then the tooth is whole again. But if you eat something containing sugar before the two hours are up, the repair work stops and the new acid that is formed continues to eat away a little deeper into the tooth. If this is repeated over a long period of time, eventually a hole (caries) will appear that can be seen with the naked eye.
Tips on avoiding caries: