The bacteria don't eat the enamel. They feed on sugars (and other carbs, but especially sugars) in the mouth, then excrete an acid that attacks tooth enamel. They live on teeth, especially in the crevices where they won't get knocked off, so that's where the acid is concentrated. Diet can help reduce the incidence of decay in the first place by reducing sugars in the mouth.