Cavities are caused by bacteria that live in the mouth and produce acid. This acid attacks the tooth enamel, causing it to break down and form a cavity.