They don't actually eat coral; like tangs, they're natural herbivores who with adapt to meat in the aquarium environment. But in the process of picking at algae near corals they sometimes accidentally snag the coral itself.
There was a great article in TFH about cowfish and their appropriate pairings, I would say about a year ago.