Most likely, you didn’t get those cavities all of a sudden. On a daily basis, your teeth are going through cycles of de-mineralization (tooth decay) and re-mineralization (repair). Acids attack the tooth enamel and cause de-mineralization and components in your saliva cause re-mineralization. In most cases a filling is not required until that de-mineralization reaches a certain depth into the tooth, or there is a break in the enamel surface. This takes time, and those “new” cavities have probably been there for years, slowly growing until they’ve reached the point where they need treatment.