That came up to my mind years ago. "How can the toothpaste work in the mouth when i clean it up with water?".
Then i just stopped doing it.
Most of the activity of toothpaste is from the silica which is abrasive. Humans don't need to soak their teeth in minerals 24 hours a day in order to not get cavities. Look up Streptococcus salivarius K12 and M18. People who have these strains are resistant to cavities. You probably know people who brush their teeth and floss and still get cavities, and total slobs who don't. Bacteria is one of the main reasons why.
Everything that counts as "damage" in the human body is oxidation, which happens when energy is produced. Various bacteria consume things, like the remnants of food in your teeth, and some even literally consume
you in order to produce energy and reproduce. Cavities are mostly due to microorganisms eating stuff in your mouth and producing oxidizing substances. Everything "rotten" i.e. "rotten teeth" is driven by microbes.
Dental plaque is literally a colony of bacteria and tartar/calculi are biofilm.
The main goal of brushing your teeth is getting rid of the stuff that can rot (= be consumed by microorganisms). The more they eat, the more they spread, and the more damage they produce. Fluoride has some minor remineralizing properties but it also kills some of the microorganisms (including some of the good ones) but it's not the main event and has become a marketing gimmick.