Here is a relevant quote from the Dogmatic Constitution on the Church, Lumen Gentium:
Those also can attain to salvation who through no fault of their own do not know the Gospel of Christ or His Church, yet sincerely seek God and moved by grace strive by their deeds to do His will as it is known to them through the dictates of conscience. Nor does Divine Providence deny the helps necessary for salvation to those who, without blame on their part, have not yet arrived at an explicit knowledge of God and with His grace strive to live a good life.
The problem is the part you quoted is almost always the only part that gets quoted and much of that quote gets ignored. .
The words “can be saved” in Lumen Gentium does not mean there is salvation any where else but that there is a possibility those outside the Church may attain salvation, not that they will, but again their salvation is due to what they know because of the Catholic church.
Lumen Gentium also says, “through
no fault of their own”. The word “no” meaning not in any degree or manner, not at all. On Catholic Answers Live an apologist once stated that no fault of their own is a very rare instance, especially today with all the knowledge we have. Which is why when we confess to God our sins, we confess that it is through our fault that we have sinned. We acknowledge our choices and actions as being our own fault.
The part you quoted also says “seek God” and “moved by grace”. God’s grace will always lead someone to the one truth and there is apparently a need to be seeking God to be saved.
One thing, also, Lumen Gentium still clearly states is that outside the Church there is no salvation:
Basing itself upon Sacred Scripture and Tradition, it teaches that the Church, now sojourning on earth as an exile,
is necessary for salvation. Christ, present to us in His Body, which is the Church, is the one Mediator and the unique way of salvation.
In explicit terms He Himself affirmed the necessity of faith and baptism(124) and thereby
affirmed also the necessity of the Church, for through baptism as through a door men enter the Church. Whosoever, therefore, knowing that the Catholic Church was made necessary by Christ, would refuse to enter or to remain in it,
could not be saved.
No where did Christ say those who do not believe in Me will be saved. No where did He say you do not have to be baptized. No where did He say you do not need the Church. Quite the opposite. Christ stated clearly that you must believe and be baptized and that the Church is the pillar and foundation of truth.
This is probably one of the most difficult teachings of the Church to accept because we all have loved ones outside the Church or maybe we ourselves are outside the Church and we want to believe we are good enough to get to heaven. We also do not want to believe that God is a mean God and would not let good people into heaven. We are not saved by being good. We are saved by grace combined with our cooperating daily in our lives with that grace.