All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad is His slave and Messenger.
Ibn ‘Abbaas, may Allah be pleased with him, narrated that the Prophet said, “Whoever has intercourse with an animal, kill him and kill the animal.” [Ahmad, Abu Daawood, At-Tirmithi, Ibn Maajah and others]
The scholars differed in opinion in regard to the authenticity of this hadeeth. Abu Daawood and At-Tahaawi classified it as Dha’eef (weak), but Al-Haakim and Al-Albaani and others classified it as Saheeh (sound).
For more benefit in this regard, please refer to the book Al-Irwaa by Al-Albaani; hadeeth No. 2348.
As regards the reason for killing the animal; according to the scholars who said that it should be killed, Ibn Qudaamah said in Al-Mughni, “So that it will not give birth to a deformed creation; and it was said: so that it would not be eaten.”
The author of Tuhfat-ul-Ahwathi said, “It was said: so that its owner would not be disgraced in this worldly life by keeping it.”
Therefore, killing the animal, according to the scholars who are of the view that it should be killed, is not because of holding it accountable or punishing it, as is clear from the mentioned justifications.
For more benefit, please refer to fatwa 197803.
Allah knows best.