Baptism is obviously essential for salvation, yet the Church through Popes has also taught that an unbaptised individual who dies without an unrepented mortal sin on their soul can be saved.
"Here, too, our beloved sons and venerable brothers, it is again necessary to mention and censure a very grave error entrapping some Catholics who believe that it is possible to arrive at eternal salvation although living in error and alienated from the true faith and Catholic unity. Such belief is certainly opposed to Catholic teaching. There are, of course, those who are struggling with invincible ignorance about our most holy religion. Sincerely observing the natural law and its precepts inscribed by God on all hearts and ready to obey God, they live honest lives and are able to attain eternal life by the efficacious virtue of divine light and grace. Because God knows, searches and clearly understands the minds, hearts, thoughts, and nature of all, his supreme kindness and clemency do not permit anyone at all who is not guilty of deliberate sin to suffer eternal punishments."
QUANTO CONFICIAMUR MOERORE
ENCYCLICAL OF POPE PIUS IX
Some would say this presents a contradictory teaching, and I’ve heard some actually question then “Why be Catholic - if this salvation is available outside of being Catholic, and potentially even available outside the Church”