Baptism is necessary for salvation:
The Lord himself affirms that Baptism is necessary for salvation. He also commands his disciples to proclaim the Gospel to all nations and to baptize them. Baptism is necessary for salvation for those to whom the Gospel has been proclaimed and who have had the possibility of asking for this sacrament. The Church does not know of any means other than Baptism that assures entry into eternal beatitude; this is why she takes care not to neglect the mission she has received from the Lord to see that all who can be baptized are “reborn of water and the Spirit.” God has bound salvation to the sacrament of Baptism, but he himself is not bound by his sacraments. – CCC 1257
In an emergency
The Church always makes an exception to certain rules for when someone is at risk of death; Holy Mother wants everyone to make heaven. This is the task entrusted to her by her Eternal Spouse:
Then Jesus came to them and said, “All authority in heaven and on earth has been given to Me. Therefore go and make disciples of all nations,baptizing them in the name of the Father, and of the Son, and of the Holy Spirit, and teaching them to obey all that I have commanded you. And surely I am with you always, to the very end of the age.” – Matthew 28: 18-20
What about Baptism?
The ordinary ministers for baptism are ordained ministers; bishops, priests, deacons. They are ordinarily expected to perform the celebration of the Sacrament. Because baptism is necessary for salvation, in emergencies and in the absence of an ordained minister, anyone including baptized Catholics, non-Catholics, non-Christians and even those who do not believe in God can administer the Sacrament, as long as they use the correct format and with the right intention i.e. to baptize. This is what the Church teaches. What matters in this case is the intentions of the one receiving, who wants to be saved and the one administering, who wants to baptize.