The best answer would be it has happened because of natural selection.
Over many generations, natural selection selects the traits that bring advantages to it's holders. In the case of the horse ancestors, the traits selected were all adaptation to living in the steppe, the vast grasslands.
Over time, the individuals who could run the fastest and avoid the predators and utilize the resource that is most available in the grasslands- grass would be the most successful, leave more offspring and eventually be more prevalent in the population.