Every sin owes a debt of penance. We are to, as repentant sinners do penance for our sins throughout all our lives.
Just like criminals being due a certain amount of corporal punishment for their crimes, a certain number of strokes of the cane, a certain number of days of harsh prison confinement, etc. In fact precisely so. It is a debt of punishment.
Penances can be and are most fittingly the opposite of what what the sin is. If we have sinned through gluttony, we should fast and give up even good food we could eat without sin, if we have sinned through anger, we should be meek and give up even lawful anger, sinned through a love of comfort, give up comforts and do what is difficult, etc…
Traditional penances are also, corporal and internal mortification, pilgrimages, prayers, etc.
The saints practiced penitential acts throughout their lives, and Christ’s life was one of sorrow and penance, though He was innocent. The merit of these penances considered all together were superabundant, more than enough.
Since there is an overflowing treasury of penance through Christ and His saints…
So, we can ask for indulgences, so that their penances can make up for ours. What this means is, the stripes we are due, the pains we are due, someone else has done, and we ask for the indulgence of God and the Church that they pay our just punishment instead of us.
And so the Church gives indulgences to certain prayers and acts, which gives them additional penitential worth to make up for the penalty due our sins.
The Holy Souls in purgatory did not sufficient do penance in this life. Therefor, they are detained in purgatory to be punished and make up for the lack of penance they did not do in this life.
We can ask that the indulgences we gain on this earth towards the punishment we are due for our sins, be applied to them too, to shorten their time in purgatory.
Since purgatorial penance is far more terrible than the penance we do in this life, this is a very charitable and worthwhile act, and we gain friends in Heaven by this charity.
So it is very simple. We are due punishment, the saints did more than enough penance, Christ did so, we substitute their punishments for ours, letting them take the strokes we are due. If this troubles a person, that is understandable… and should make a person all the more penitential, so rather than only gaining indulgences, one is part of the gift of them in the next life.