I disagree with the teaching that official membership in the Catholic Church is unnecessary for salvation. I feel that past popes and councils have clearly taught that one must be a Catholic to be saved. I thought that it is impossible to enter heaven if mortal sin is on your soul. Would believing this contradict any infallibly defined teaching? Has the Church in recent years infallibly defined that being a Catholic is not necessary for salvation?
A literal understanding of being an official/external member of the Catholic Church as necessary for salvation is not the teaching of the Church. A priest, Father Feeney, tried to preach that message and was excommunicated in 1953. This error is now named after him and is commonly called Feeneyism or The Boston Heresy.
The Holy Office in 1949 wrote to Fr. Feeney and asked him to accept the Church’s definition/understanding of the doctrine Extra Ecclesiam nulla salus:
Therefore, that one may obtain eternal salvation, it is not always required that he be incorporated into the Church actually as a member, but it is necessary that at least he be united to her by desire and longing.
However, this desire need not always be explicit, as it is in catechumens; but when a person is involved in invincible ignorance God accepts also an implicit desire, so called because it is included in that good disposition of soul whereby a person wishes his will to be conformed to the will of God.
This was no different from what Pope Pius IX said in his allocution Singulari Quadam in 1854:
It must, of course, be held as a matter of faith that outside the apostolic Roman Church no one can be saved, that the Church is the only ark of salvation, and that whoever does not enter it will perish in the flood. On the other hand, it must likewise be held as certain that those who live in ignorance of the true religion, if such ignorance be invincible, are not subject to any guilt in this matter before the eyes of the Lord. But then, who would dare to set limits to this ignorance, taking into consideration the natural differences of people., lands, native talents, and so many other factors?
Given that this error has led to a priest being excommunicated, I would recommend that you prayerfully reconsider your stance against the Church’s teachings. We are not free to pick and choose parts of the Catholic faith. Even in areas that we have difficulty we should humbly and prayerfully allow ourselves to be taught by the Church.