Hercules killing snake as baby

This story is different from Hercules killing Hydra

Like most authentic heroes, Heracles had a god as one of his parents, being the son of Zeus and a mortal woman named Alcmene. Zeus's wife Hera was jealous of Heracles, and when he was still an infant she sent two snakes to kill him in his crib. Heracles was found prattling delighted baby talk, a strangled serpent in each hand.

Whereas the same story has been told in a different way in Krishna story

Aghasura (अघासुर), is a demon (rakshasa) in Hindu and Vedic mythology.

Krishna Subdues the Serpent Aghasura

He was one of King Kamsa's generals,[1][2] younger brother of Putana and Bakasura.

A study of the Bhagavata Purana; or, Esoteric Hinduism by Purnendu Narayana Sinha, p. 247 mentions Agha as one of the tribes in alliance with Kamsa. Kamsa With the alliance of the Magadhas (people of Magadha or ancient Bihar) and with the help of Pralamba, Baka, Chanura, Trinavarta, Agha (अघा), Mushtika, Arishta, Dvivid, Putana, Kesi, Dhenuka, Vana, Bhouma and other Asuras, tormented the Yadavas. They fled away to the kingdoms of Kuru, Panchala, Kekaya, Salva, Vidarbha, Nishadha, Videha, and Kausala. Only some remained behind, following the behest of King Kamsa.[3]

The Bhagavata Purana states that Aghasura assumed the form of an enormous serpent.[4] Krishna's companions, the cowherd boys, entered its mouth, mistaking it for a mountain cavern. After seeing this, Krishna then came to their rescue, killing Aghasura. (The killing of Aghasura by Lord Krishna is narrated by Sage Sukadeva to king Parikshit in Srimad Bhagavatam).

King Kamsa made many attempts on the life of Krishna, all of them failing. Then he sent Aghasura to kill Krishna, who did so willingly knowing that his elder brothers Putana and Bakasura were killed by Krishna. He assumed the form of 8-mile-long serpent, disguising his open mouth against a mountain. All the cowherd boys entered the mouth of the demon mistaking it to be a cavern.

Krishna entered the serpent upon his arrival and then increased the size of his own body. In response, the demon too extended his own body's size. Nonetheless, his breathing stopped. Suffocating, his eyes rolled here and there and then popped out. The demon's life force, however, could not pass through any outlet, and therefore it finally burst out through a hole in the top of Aghasura's head. Thus, the demon meet his end by Krishna's hand.