Short explanation: The grace of baptism can be given by God to anybody He wishes, even if they are not sacramentally baptized.More complete explanation:
There are two fundamental theological principles at work here: (a) God never withholds his grace from those who do what they can, and (b) God is not limited to the sacraments. God can (and does) sometimes give the grace of baptism to people who did not receive the sacrament of baptism. There are several known circumstances where this would always happen:
(1) “Baptism of Desire”. Imagine the following scenario. A person is given the gift of faith, and wishes to convert to Christianity, and becomes a “catechumen” (a person taking the courses that prepare you for baptism). Then that person dies before they could be baptized. Would God send such a person to Hell because they hadn’t been sacramentally baptized? Of course not. They did what they could, so God would certainly not withhold from them the grace that they desired and were working towards. Since these catechumens receive the grace of baptism without actually being sacramentally baptized, we say that they received the “baptism of desire.” It is not a sacrament, but the same grace is received.
(2) “Baptism of Blood”. If a person is not sacramentally baptized, but gives their life for the sake of Jesus, or for the sake of the Church, or for the sake of Christians, or the like, then certainly they would win the crown of martyrdom just as surely as any baptized martyr. Although we call this “baptism of blood ”, it is not a sacramental baptism... but God gives the grace of baptism to all such holy martyrs.
How many more ways are there to receive the grace of baptism without being sacramentally baptized? God only knows.
Thought Experiment:
Imagine Saint Peter standing at the Pearly Gates one day as a newly departed soul arrives. Saint Peter says to him, “Welcome to heaven! We’re very happy to have you with us! How long will you be staying? Oh, what am I saying?! <smacks forehead> I mean, what kind of mansion would you prefer? I see here that you gave your life defending a church from a gang of hoodlums who were trying to burn it down! That’s wonderful; martyrs are a rare breed these days! So just sign here, and then you can ... um, wait a second ... oh dear me ... it says here that you were just a catechumen and were never baptized. Tsk, tsk. Well, you know what that means!” He pushes a button and a trapdoor opens under the new arrival who plummets from sight. Saint Peter says to himself, as if to drown out the rapidly fading scream, “Man, I hate it when that happens.”
Seem possible? I don’t think so either. Nor does the Church.