How does toothpaste kill bacteria that cause cavities?
Many toothpastes contain fluoride.
There is an ongoing debate as to whether adding fluoride to toothpaste actually is an effective method of killing bacteria. Despite the fact that fluoride has bactericidal properties (the ability to kill bacteria), when added to toothpaste, some studies suggest that fluoride does not have a significant effect on killing bacteria. In fact the antibacterial compound triclosan, the ingredient in antibacterial soap that kills bacteria, out preforms fluoride when added to (non-fluoride) toothpaste. Some toothpastes contain triclosan however tricolsan is toxic to fish and birds, additionally some recent studies have been conducted that suggest that triclosan may be carcinogenic (many companies have started to phase this ingredient out of their products).
One of the theories that has been proposed as to why fluoride in toothpaste isn't highly effective at killing bacteria is that the bacteria aren't exposed to the fluoride for a long enough amount of time to kill them (hopefully you rinse your mouth out after brushing). Fluoride kills bacteria is by preventing an enzyme that helps make DNA from working (the bacteria can't make DNA so it can't replicate or function and it dies). Fluoride is theorized to strengthen our teeth in other ways beyond the scope of this article (it would be a discussion better suited for Human Anatomy & Physiology I).
The reason we brush our teeth is actually not to kill bacteria but to remove bacteria. When we brush our teeth we are actually doing what some microbiologist like to call a mechanical (think of your toothbrush as a machine) method of removing bacteria; bacteria create a layer on your teeth (like algae on a rock in a creek) and when you brush your teeth the bristles "scrape" the bacteria off our teeth (like using your toes to remove the algae from the rocks). In fact according to this study we don't even need to use toothpaste to effectively brush our teeth.
Flossing also only removes bacteria.
If you really want to kill some bacteria use mouthwash, most are alcohol (this isn't drinking alcohol) based and some whitening mouthwashes have hydrogen peroxide both of which kill bacteria.
I hope this helps!