Before us is Mishnah 6 in the fourth chapter of Tractate Bava Kamma, along with the halachos concerning the obligation to put to death a cow that killed a person - and similarly any animal that killed - and the possibility that the owner of such an animal would be obligated to pay kofer (ransom).
The Foundation of the Mishnah - The Need for Intent:
For the animal to be liable to the death penalty, it had to have intended to injure and kill a person. If this was not its intent, it is not liable to death for this act. This principle is learned from the wording of the verse "Hashor yisakel vegam be'alav yumas" - the verse equates the death of the animal to the death of a person who is executed: just as a person who murders is not liable to the death penalty unless he intended to kill, so too the animal is not liable to stoning unless it intended to kill.
The Scenario of the Mishnah:
An ox that was rubbing against a wall - a cow rubbing against a brick wall, as if trying to scratch its back - and the wall fell on a person sitting behind it, and as a result of the bricks falling on him he died, Heaven forbid. Since the cow did not intend to injure a person, it is not liable to the punishment of stoning.
This is not to say that the victims or their relatives will not bring the owner to beis din and warn him that his animal is dangerous, since it knocks down walls and kills people. If this happens three times, the animal may become a mu'ad - meaning, the responsibility is now cast upon its owner to guard it so that it will not knock down any more walls and harm people.
And if the incident occurs a fourth time: the animal itself is exempt from stoning, since it did not intend to harm a person, but its owner is obligated to pay the kofer. For his negligence is severe - he has a mu'ad in his possession, a mu'ad for knocking down walls and harming people, and therefore he is completely responsible to pay the kofer.
The Cases of the Mishnah in Detail:
"Shor shehayah misachech bakosel venafal al ha'adam" - As explained above: the ox rubbed against the wall, the wall fell on a person and killed him, and there is no intent here to kill a person.
"Niskavein laharog es habehemah veharag es ha'adam" - The ox sought to attack another animal, missed it and hit a person, and the person died. Since it did not intend to kill a person, it is not liable to the punishment of stoning.
"Oved kochavim veharag ben Yisrael" - The ox intended to kill a non-Jew. One who kills a non-Jew, even though this is murder, is not punished with the death penalty, and for this reason the ox is also not stoned for it. Therefore, even though in practice it killed a Jew, it is not put to death.
"Lenefalim veharag ben kayama" - A nefel is a baby born that is not viable, such as a premature baby that cannot survive and is merely considered as someone who has not yet died, and whose entire lifespan is less than thirty days. Because of this, he is not considered fully alive, and one who kills him is not liable to death. Therefore, even the ox that intended for a nefel, but in practice another person got in its way and died - is not stoned.
In all of these cases the animal is exempt from stoning, because they lack the intent to kill a person whose killing carries a liability of death.