It "gains" them by the show of mercy and compassion expressed by the community in which the "sinner" lives and worships. AND you have no idea of the extent to which they have repented of their sins, pain and brokenness.  It's really as simple as that IMHO, but you've apparently been conditioned to place undue faith in the imperial legislation enacted by medieval Rome. Just take the phrase "state of grace" for example... what business does some Roman prelate have in crafting this made-up term and, even more egregiously, passing judgment on the "state of one's soul?"

The apostles and early church fathers were charged with preserving the early Rule of Faith (before there were canons, a magisterium and the CCC), they had no business adding to it... the early fathers clearly understood that to Add to the early Christian faith was to Err... but add they did and that's why the RCC finds itself painted in a corner with no feasible way out, except perhaps to admit a gigantic mea culpa or two!