In the first narration (Sahih al-Bukhari 3019, Sahih Muslim 2241a), an ant stung one of the prophets, so he ordered the village of the ants to be burned. Allah then revealed to him, in the meaning: because one ant stung you, you burned a nation among the nations that glorify Allah? Sahih Muslim uses a word that means he destroyed them.
In the second narration (Sahih al-Bukhari 3319, Sahih Muslim 2241b), a prophet stopped to rest under a tree and an ant stung him. He ordered his belongings to be taken out from under the tree, and then ordered the ants' home to be burned. Allah revealed to him: «فَهَلاَّ نَمْلَةً وَاحِدَةً». The meaning is: why not just the one ant that hurt you?
The hadith ends there. It does not tell what the prophet said or did after the revelation.