Praise be to Allaah.
What you did was not haraam and was not a sin; in fact it was obligatory (waajib) upon you, because this comes under the heading of saving lives which is encouraged in Islam. Allaah says (interpretation of the meaning):
“… and if anyone saved a life, it would be as if he saved the life of all mankind …” (al-Maa’idah 5:32)
It was reported from Ibn ‘Abbaas, from Murrah al-Hamadaani, from ‘Abd-Allaah and from a number of the Companions of the Messenger of Allaah concerning the Tafseer of this aayah: “…and if anyone saved a life means, saved someone from death, it would be as if he saved the life of all mankind in the eyes of the person whose life was saved.” (Tafseer al-Tabari, 6/199)
Saving the life of a person whose life is protected in sharee’ah is obligatory (waajib) on whoever is able to do so. Saving a life is one of the five essentials which Islam came to protect (they are, life, sanity, wealth, religion and lineage). With regard to the prayer, you have to repeat it after you have helped the child. And Allaah knows best.
Sheikh Muhammed Salih Al-Munajjid