Without knowing more context there are two possible explanations:
The pronoun »ihr« refers not to the horse, but to a female person:
Frau Moser hat mir ihr Pferd verkauft und war auch beim Transport dabei. Gestern ist mein Pferd in einen neuen Stall gezogen. Und ich habe ihr dabei geholfen.
In this case »ihr« refers to »Frau Moser« which is a female person.
The horse is female (a mare), and the owner has a relationship to it like to a pet. Pets (and android robots, and sometimes even vehicles like cars or ships) are often treated as persons, and for persons there is relatively young exception from the grammatical gender-matching-rule:
- If the grammatical gender of a person is different from its/his/her biological gender, then the personal pronoun can also match with the biological genders:
- Das Mädchen hat schöne Beine. Sie ist sehr hübsch.
- Dieses Arschloch hat mich einfach gekündigt. Ich hasse ihn!
»Das Mädchen« is grammatical a neuter noun, but the person it names is biological female. So it is possible, to use the female pronoun »sie«.
»Das Arschloch« is also grammatical neuter, but no person is biological neuter (even assholes are male or female). In my example the person is male, so it is possible to use the male pronoun »ihn«.
Referring to the biological gender at pets is still rare, but referring to persons via their biological gender also was not common when I went to school (born 1965).
There is even a very famous children's book from the swiss author Johanna Spyri which has two parts. The title of part 1 is »Heidis Lehr- und Wanderjahre«, but part 2 has the title
Heidi kann brauchen, was es gelernt hat
(engl:: Heidi can need what it has learned)
This is, because Heidi is a little Girl (Mädchen), and this word is grammatical neuter in German. So the pronoun had to be the neuter es. This book was published in 1881. Now (2016) this is considered to be wrong. Now it must be »... was sie gelernt hat« because the word »Mädchen« doesn't appear in the title, and the girl is identified just by her name. When you call a person by its name, then the name always inherits the gender from the biological gender of the named person. (This obviously was not true in Switzerland in 1881).
I was talking about daily usage of language. The official rules still do not allow referring to the biological gender. But it always takes decades till daily usage becomes official rules.