Tooth decay is caused by certain types of bacteria (germs) that live in your mouth. When they stick to the film on your teeth called dental plaque, they can do damage.
The bacteria feed on what you eat, especially sugars and starch (bread, crackers, cookies). Within about 5 minutes after you eat, or drink, the bacteria begin making acids as they digest your food.
Those acids can break into the outer surface of the tooth and melt away some of the minerals. Your saliva can balance the acid attacks if they don’t happen very often. However if : your mouth is dry, you have a lot of these bacteria, or you snack frequently, then acid causes loss of tooth minerals. This is the start of tooth decay and leads to cavities.