The acid dissolves the minerals that make your tooth enamel hard. The surface of the enamel becomes porous - tiny holes appear. After a while, the acid causes the tiny holes in the enamel to get bigger until one large hole appears. This is a cavity. It's important to see your dentist before a cavity forms so that the plaque you can't reach with your toothbrush or floss can be removed.
Sugar plays a harmful role in tooth decay.
The bacteria that form together to become plaque, use sugar as a form of energy. They multiply faster and the plaque grows in size and thickness. Some of the bacteria turn the sugar into a kind of glue that they use to stick themselves to the tooth surface. This makes it harder for the bacteria to get washed away with your saliva. We feed the bacteria in our mouth everytime we eat carbohydrates.