While some Catholics may believe it, that is not what the church teaches...
Section 1260 of the Catechism of the Catholic Church begins by saying, Since Christ died for all, and since all men are in fact called to one and the same destiny, which is divine, we must hold that the Holy Spirit offers to all the possibility of being made partakers, in a way known to God, of the Paschal mystery. Those words are quoted from Vatican IIs Pastoral Constitution on the Church in the Modern World (#22); the Catechism links them to the same Councils Dogmatic Constitution on the Church (#16) and its Decree on the Churchs Missionary Activity (#7).
Section 1260 of the Catechism continues: Every man who is ignorant of the Gospel of Christ and of his Church, but seeks the truth and does the will of God in accordance with his understanding of it, can be saved. It may be supposed that such persons would have desired Baptism explicitly if they had known its necessity.