How did David respond when confronted with his sin?
2 Samuel 12:13
So David said to Nathan, “I have sinned against the LORD.” And Nathan said to David, “The Lord also has put away your sin; you shall not die.
David did not ask for forgiveness, he admitted he sinned against the LORD and the LORD responded.
One does not ask for forgiveness. One admits they sin against the LORD and by making such an admission, they place themselves in the hands of the LORD.
No one asked John the Baptist for forgiveness. They simply confessed their sins to him. Confessing sin before the crucifixion and resurrection, that is, before the only sacrifice which had the efficacy to deal with sin, was just that. A confession. Perhaps those who made the confession hoped for forgiveness, but such hope is not stated.
Now Christ is at the right hand of God, and He is a believer's advocate (1 John 2:1).
1 John 1:
8 If we say that we have no sin, we deceive ourselves, and the truth is not in us. 9 If we confess our sins, He is faithful and just to forgive us our sins and to cleanse us from all unrighteousness. 10 If we say that we have not sinned, we make Him a liar, and His word is not in us.
Conclusion
Forgiveness comes only when confession is coupled with a right belief about Jesus.
John 8:24:
Therefore I said to you that you will die in your sins; for if you do not believe that I am He, you will die in your sins.”
That fullness of belief in Jesus was not possible until He was crucified and resurrected. Only then could one have faith their confession was not dependent upon the Mosaic Law but the Christ, the Son of God.