You can prevent cavities by practicing good oral hygiene habits, including brushing twice a day, flossing daily, and visiting your dentist regularly for check-ups and cleanings. Additionally, you can reduce your risk of cavities by limiting sugary and acidic foods and drinks, and by using fluoride toothpaste and mouthwash.