The canons don’t say anything about the person doing the baptizing in case of emergency, which would be the only case where I can imagine a non believer doing the baptizing. My guess is that if the person is in danger of death and the person doing the baptizing uses the proper matter and form with the intent to fulfill what would be the wish of the person being baptized, then it’s valid and licit. The focus seems to be on the matter and form.
**Can. 865 §2. An adult in danger of death can be baptized if, having some knowledge of the principal truths of the faith, the person has manifested in any way at all the intention to receive baptism and promises to observe the commandments of the Christian religion.
Can. 868 §2. An infant of Catholic parents or even of non-Catholic parents is baptized licitly in danger of death even against the will of the parents.
Can. 871 If aborted fetuses are alive, they are to be baptized insofar as possible.**
Fraternally,
Br. JR, OSF