Your teeth and bones contain calcium phosphate crystals called hydroxyapatite
Cavities occur because these apatite crystals are more soluble under acidic conditions
So when you have food/plaque built up on or between your teeth, bacteria like S. mutans metabolize carbohydrates into lactic acid and other acidic byproducts
When these acids are left sitting on you teeth they dissolve apatite leading to holes in your enamel which trap food and harbor even more bacteria
On top of that, simple sugars in things like candy are more quickly metabolized and get trapped between teeth more easily, and some foods/drinks like soda contain acidic ingredients like phosphoric acid
The mechanism by which fluoride "works" to prevent tooth decay is by reacting with hydroxyapatite to covert it to fluoroapatite, which dissolves at somewhat lower pH (4.5 instead of 5.5)
The problem is that this requires prolonged contact time with your teeth (at least 30 minutes) making fluoridated water, fluoride rinses, and the way most people brush their teeth practically useless
Beyond that systemic fluoride consumption can have unintended negative effects like fluorosis (white spots on teeth) and accumulation in the bones and brain
By far the two better alternatives are baking soda and nano-hydroxyapatite toothpastes
Baking soda or bicarbonate works by directly neutralizing acidity, and can be used to make homemade toothpaste or found as an ingredient in many fluoride-free toothpastes
Nano-hydroxyapatite is set to become the next dental industry gold standard, as it can bind to the surface of enamel and directly replace lost enamel, though it also needs ample surface contact time similar to fluoride
To prevent cavities:
- prioritize whole foods without added sugars/phosphates/acids
- eat fruits and vegetables that build a healthy oral microbiome and prevent bacterial overgrowth
- brush after meals to neutralize acidity
- use nano-HA toothpaste to remineralize teeth
- don't rinse your mouth after brushing