Why do horses have so much muscle when all they eat is grass and hay?

Because most of them are being ridden and exercised everyday, and that builds up muscle. Horses are very muscular animals. They also run around in their pastures too.