Unless it did it again. I would apply the stun everytime it attacked me until it quit doing it. Each time it got up, I'd act like nothing happened and we'd go on. Horses are pretty sharp. It wouldn't hold the stun gunning against me.
Animals have a very heightened sense of justice.
They know instinctively that certain actions cause certain reactions. We as humans start justifying degrees and motives and then justice becomes murky. In animals, justice is cut and dried and accepted. It would quickly learn to stay away from me. Let's transfer this to a herd dynamics situation.