When we go to confession there are a few conditions that apply.
First the priest must be a validly ordained priest who has faculties, (permission from the local bishop) to hear confessions and grant absolution.
We must not hide from him any mortal sins, and we must be contrite, or sorry for having offended God by sinning. Perfect Contrition is sorrow for our sins because it offends God, Imperfect Contrition is sorrow for our sins motivated by our fear of punishment in Hell.
The priest acts as a representative of Christ, and has been given the authority that Christ gave to the Apostles to forgive sins.
Theoretically a priest could tell you that he does not feel you are making an effort to stop any habitual sins, and withold absolution, or the absolution could be invalid, (not effective) because you willingly withheld information about a mortal sin, or where not contrite.
Lets say you make a good confession, and the priest absolves the sins. Your sins are forgiven. There is still the matter of restititution, or the temporal punishment which is not lifted or removed by the fact you are now forgiven.
If you have wronged someone, lets say took something from them, part of justice is to make restitution. If they are unaware of the theft, or who did it, it is OK to make restitution without identifying yourself. So too with God, you may be forgiven, but you still have the penalties for the sins even though they are forgiven. That is what the aspect of the penance is.
Penances in the early Church people where barred from reception of communion, sometimes until their deathbed, or could only attend the Mass after the Sermon, (they where permitted only for the Liturgy of the Word) and then where excluded with the Catechumens from the Eucharitstic Liturgy. From the times of the Apostles to the time of St. Gregory the Great (6th Century) these penances where to our minds very severe. But then again, they understood how sin was a form of murder of the soul. Gradually the Church allowed anyone to stay throughout the Mass, and allowed those forgiven of sins to recieve communion as a Pastoral provision in order to provide graces to help them avoid further sins. But the punishment for sins was still an issue. Less severe penances and the opportunity to gain Indulgences where granted by the Church based on the penances imposed in the Early Church, but rather than the strict punishments that the Early Church imposed the Church granted that the same punishment could be granted by pius acts, making a pilgrimage, doing acts of charity for the poor or feeding or caring for the sick, offering certain prayers etc. If there was a “balance” left when you die, God provided for us a place where we could finish the punishment that justice mandates we pay for our sins, Purgatory, where we are purified of any final punishment due to us, so we may be purified, (as Scripture tells us, like a refiners fire. or As gold is tested by fire.)
All of this was made availible to us by the Merits of Christ during His Passion and Death on the Cross, not because we are deserving or because we can do it on our own, but because our actions are sanctified by uniting ourselves to Him and His work. Otherwise our penances are simply human works.
Summing it up; A priest acts by the power of Christ to forgive sins.
We are forgiven by Christ’s actions through the priest, and our sorrow for our sins, united to our faith in Christ. There remains the debt, or punishment that needs to be paid, and we can do that through many ways, acts of charity, prayer, (not through money) and only for sins of the past, we can’t build up credit or get out of jail free cards. These punishments are acceptable to God when we unite with Him and do the penance with the desire to remain faithful to Him.
No Magic, only Divine Justice. (Edited to correct some of my spelling [i:2y58sqfr]SINS[/i:2y58sqfr])