Cavities are cause by 3 factors: carbohydrates(like sugar), bacteria, and time. When bacteria are present in the mouth, the feed on sugars. The by-product of their digestion is acid, which softens teeth with time and creates holes for the bacteria to live in ('cavities'). When the bacteria hide in these holes and can no longer be removed with your toothbrush!
So how do these bugs get in our mouths? We catch them from each other. Babies are born without this bacteria, and studies have shown that their uninfected mouths don't get cavities even if they eat a lot of sugar. However, once they share a spoon, cup, or even a kiss from a family member who has cavities, the bacteria enter their mouths.
What does this mean? Dental caries and gum disease are contagious. This is why everyone in the family should have excellent dental health. This applies to couples as well! See the following New York times page for an interesting article: