Each Gemara deserves its own answer individually (feel free to ask a more specific question). For example an act of self-sacrifice might be like overriding the exact sin they had done - though not the exact situation.
When we say that someone must be in the same situation, presumably if it is equivalent where the person would have sinned previously, but post tshuva does not or would not do that same sin, that is logically like being in the same situation. And so when someone is willing to give up their life (for example) in many ways that shows a self control that is very powerful and demonstrates they would not have sinned.
We also say that Hashem sometimes considers intentions for a good deed like the action was done. This is specifically when the person would do the action if not for something stopping him.
אמר רב אסי אפי׳ חשב אדם לעשות מצוה ונאנס ולא עשאה מעלה עליו הכתוב כאילו עשאה (קידושין מ.)
Based off of this principle perhaps he is considered to have said Vidui and done Tshuva.
Finally, there is a Gemara on Chagiga 5a that if someone regrets a sin they are forgiven immediately.
א״ר חנינא בר פפא כל העושה דבר ומתחרט בו מוחלין לו מיד שנאמר ולא יראוני הא יראוני מוחלין להם מיד
I would argue that you can see that someone might be forgiven, but perhaps it might not be considered like Tshuva where the act is erased from having ever been performed or considered like a Mitzvah. And so there are different levels of forgiveness, tshuvah etc...