A cavity is formed after a long-term biofilm is left on the teeth. If you have biofilm on a tooth, whether it's soda, sticky foods, or whatever, and it's not removed, then it causes acid.