We ask the saints to pray for us. We pray for the souls in purgatory. Only those who die in a state of grace are in purgatory.
When you commit a sin after baptism, there is a temporal punishment you must pay.
An example: A lapsed Catholic murders a man. His temporal punishment is life in prison. He confesses the sin (with true repentance) and is absolved. He still must pay the temporal punishment either in prison for life or in purgatory.
We can offer our penance, sufferings, prayers, and indulgences on behalf of our sins to shorten purgatory.
An indulgence pays for our temporal punishments that we earn from sin that we commit. When we die, if we have not paid for all of our temporal punishments, we will pay for them in purgatory.
A partial indulgence remits part of our temporal punishment. A plenary indulgence remits all of our temporal punishment we have earned up to that point.
Note: Baptism remits all sins and temporal punishment. Confession remits only sins.
We can gain indulgences for the poor souls in purgatory and pray for them.