The priest acts in the person of Jesus. The priest hears the confession and says the words of absolution, but it is Jesus who forgives the sins. Similar to how during the consecration, the priest takes the role of Jesus by saying the prayer of consecration.
Recently (12/01/20) at Fr Z’s Blog (here) in answer to a question he explains what happens during confession. There was a very good image attached which I attach here.(Please Note: This uploaded content is no longer available.)
DISCLAIMER: Catholic Answers has turned over the archive to Catholic-Questions.org and no longer owns, manages, or moderates the forums. For additional apologetics resources please visit www.catholic.com.