As always, some context is key to understanding what's happening in this passage.
1Then the LORD sent Nathan to David. And he came to him and said, There were two men in one city, the one rich and the other poor. 2The rich man had a great many flocks and herds. 3But the poor man had nothing except one little ewe lamb Which he bought and nourished; And it grew up together with him and his children. It would eat of his bread and drink of his cup and lie in his bosom, And was like a daughter to him. 4Now a traveler came to the rich man, And he was unwilling to take from his own flock or his own herd, To prepare for the wayfarer who had come to him; Rather he took the poor mans ewe lamb and prepared it for the man who had come to him. 5Then Davids anger burned greatly against the man, and he said to Nathan, As the LORD lives, surely the man who has done this deserves to die. 6He must make restitution for the lamb fourfold, because he did this thing and had no compassion. 7Nathan then said to David, You are the man! Thus says the LORD God of Israel, It is I who anointed you king over Israel and it is I who delivered you from the hand of Saul. 8I also gave you your masters house and your masters wives into your care, and I gave you the house of Israel and Judah; and if that had been too little, I would have added to you many more things like these! 9Why have you despised the word of the LORD by doing evil in His sight? You have struck down Uriah the Hittite with the sword, have taken his wife to be your wife, and have killed him with the sword of the sons of Ammon. 10Now therefore, the sword shall never depart from your house, because you have despised Me and have taken the wife of Uriah the Hittite to be your wife. 11Thus says the LORD, Behold, I will raise up evil against you from your own household; I will even take your wives before your eyes and give them to your companion, and he will lie with your wives in broad daylight. 12Indeed you did it secretly, but I will do this thing before all Israel, and under the sun. 13Then David said to Nathan, I have sinned against the LORD. And Nathan said to David, The LORD also has taken away your sin; you shall not die. 14However, because by this deed you have given occasion to the enemies of the LORD to blaspheme, the child also that is born to you shall surely die. 15So Nathan went to his house.
(2 Samuel 12:1-15 NASB)
Nothing in this account is remotely close to what roman catholics claim regarding forgiveness.
We never see Nathan tell David that he has absolved him of his sins....it is the Lord who has forgiven David.
Now compare to the catholic confession to a priest.
"I absolve you from your sins in the name of the Father and of the Son and of the Holy Spirit."
Some will try to claim the son dying is penance.
No.
This was nothing David had any part in. It was entirely the Lord's doing as noted in verse 15.
The reason for the boy dying is stated in verse 14.....so that the enemies of the Lord shall not have a means to blaspheme.
But also notice how quickly the Lord forgave David. One David acknowledged his sin against the Lord Nathan told David the Lord had taken away his sin.
When we confess our sins before Christ he is sure to forgive and quick to forgive.
If we confess our sins, he is faithful and just and will forgive us our sins and purify us from all unrighteousness (1 John 1:9 NASB).
He also removes our sins as far as the east is from the west (Psalm 103:12).
God works through those who serve Him.
God can do all things.