Since I brush and floss twice a day does that ensure that I will not have cavities?

A cavity can develop a few different ways.  The amount of bacteria in your mouth can cause an acidic PH if your diet is high in sugar and carbohydrates.  It is extremely important to drink plenty of water to neutralize the acid.
Decay can also occur when the tooth has become damaged by clinching or grinding.   Once a crack or chip has occurred, bacteria can penetrate the tooth and can create a cavity. The root causes of cavities include poor oral hygiene, clinching or grinding and high sugar intake.