Baptism, the Church teaches, is the only assured means of receiving saving graceBaptism is a sacrament that the Church teaches is necessary for salvation. But through God's mercy, even those who may not have been sacramentally baptized may still receive the same graces.
The Catechism of the Catholic Church states: “The Lord himself affirms that Baptism is necessary for salvation … 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” (1257).
So baptism is necessary for salvation for those who have heard the Gospel and have access to the sacrament. But, the necessity of water baptism is understood by the Church to be a normative and not absolute necessity. It is possible in certain circumstances to be saved through “baptism of blood” (martyrdom) or “baptism of desire” (this could an implicit desire on the part of a person who has not even heard the name of God): “Those who die for the faith, those who are catechumens, and all those who, without knowing of the Church but acting under the inspiration of grace, seek God sincerely and strive to fulfill his will, are saved even if they have not been baptized” (CCC 1281).
The most succinct response to this question is provided by this statement in the Catechism: God has bound salvation to the sacrament of Baptism, but he himself is not bound by his sacraments (CCC 1257). God has given us certain norms to follow in our path to him, but is always above them himself and can use whatever creative means he chooses to bring souls home to him.
Although the matter and form of the sacrament may not have been observed in the case of a particular individual, “baptism by blood” or “baptism by desire” indicates that, through God’s mercy and grace, that person has died within the embrace of the Church.