It's a little confusing to me to understand the process. Can someone explain this?
Coming at this from a Lutheran angle.
Christ gave His apostles the authority to forgive sin in John 20:23. The apostolic ministry is preserved in the pastorate, as the Apostles established bishops and presbyters to pastor the churches in their stead.
As such pastors speak and act with apostolic authority, in the name and stead of Jesus Christ, to pronounce forgiveness of sin.
It isn't the pastor who is doing the forgiveness, the forgiveness is from God, and the authority to forgive belongs to Jesus Christ; the pastor is acting as a servant of Christ, in the name and stead of Christ to pronounce forgiveness of sins.
When the pastor says "I forgive you" he is not speaking for himself, he is speaking in the name and by the authority of Jesus--it is God who forgives us, and our forgiveness is found alone in Jesus' all-sufficient atoning work on the cross.
This pastoral service is the Office of the Keys which Christ gave to the whole Church when He said to Peter, "I will give you the keys of the kingdom of heaven, and whatever you bind on earth shall be bound in heaven, and whatever you loose on earth shall be loosed in heaven." (Matthew 16:19). While speaking to Peter, Peter is here instead representative of the whole--it is not to Peter only, but all the Apostles and to the Church as a whole (Matthew 18:18, John 20:23). The office of the keys is exercised through the pastorate, for the good of the Church. As Lutherans reject the notion of sacerdotalism, that pastors are given a special indelible grace which makes them in any way inherently different than lay Christians, that pastors exist as a kind of special priestly of Christian. The pastoral office is a vocation that comes from the Church for the good of the Church, as it is the Church which calls and ordains pastors. It is through this pastoral vocation, in the exercising of the apostolic ministry, the office of the keys, to preach the Word and administer the Sacraments; and therefore to pronounce the forgiveness of sins in Christ's name, authority, and stead.
-CryptoLutheran