There are three parts to repentance: contrition, confession, and bringing forth fruits worthy of repentance (aka making satisfaction). Purgatory mostly has to do with the third part.
Sins are forgiven when the priest absolves you after you confess your sins with contrition. You are restored to the friendship of God. But, we still must bring forth fruits worthy of repentance as Scripture says–that is, we must attempt to “expiate” the temporal stain of our sin.
Here’s an analogy: if I steal a five dollar bill from you, I have sinned. I confess my sin with a contrite heart and am absolved by the priest. Am I now totally clean? No–I still have the ill-gotten five dollars in my wallet. I still carry with me that injustice–that stain from my sin. I can’t just say Jesus paid the price of that sin and pocket my ill-gotten gains. I need to get rid of those gains. What is the fruit worthy of my repentance for stealing? To give it back, or, if that is not possible, to give it as alms or make some other amends.
Every sin carries with it some kind of stain of injustice, even if intangible, including honor we should have given to God which we did not. Most priests assign prayer as a penance for this reason, since by it we give honor and love to God.
Penances assigned by the priest are not meant to make full satisfaction. We can and should do more ourselves through prayer, fasting, and almsgiving as the Scriptures demonstrate, especially during the penitential days and seasons of the Church (Fridays, Lent, etc.). Almsgiving is traditionally associated with sins against neighbor, fasting with sins against self, and prayer with sins against God (which all are).
God also can and often does send His own punishments (see e.g. Hebrews 12:4-11) which, if we bear them patiently, also expiate our sins.
The Catechism of the Catholic Church sums this all up:
1473 The forgiveness of sin and restoration of communion with God entail the remission of the eternal punishment of sin, but temporal punishment of sin remains. While patiently bearing sufferings and trials of all kinds and, when the day comes, serenely facing death, the Christian must strive to accept this temporal punishment of sin as a grace. He should strive by works of mercy and charity, as well as by prayer and the various practices of penance, to put off completely the “old man” and to put on the "new man."84
If we don’t make sufficient satisfaction in this life, but die in the friendship of God, the remaining expiation must be accomplished before entering Heaven. We can’t bring that injustice, those ill-gotten gains, with us. This final purification is what we call purgatory.
Finally, since we are all one Body and should bear each other’s burdens, as Jesus says, we can offer our prayers and penances in satisfaction for another’s sins. This is why we pray for the dead. The Church, through the power of binding and loosing, by virtue of the superabundant satisfactions of the whole body of Christ, can also remit some or all of the need to make satisfaction (this is called an indulgence).