I think you’ve asked a good question. I would conclude that you are reading in the NIV version of the Bible, and thus are referring to Hebrews 12:6:
NIV Hebrews 12:6 because the Lord disciplines those he loves, and he punishes everyone he accepts as a son."
6 "For the Lord disciplines the one he loves and chastises every son he accepts." Hebrews 12:6 The NET Bible
We should observe that only the NIV (in all the major translations I checked) translates "punishes." All the others render it either "scourges" or "chastises/chastens."
11 My child, do not despise discipline from the Lord, and do not loathe his rebuke.
12 For the Lord disciplines those he loves, just as a father disciplines the son in whom he delights. Proverbs 3:11-12 The NET Bible
Some of the Hebrew saints seemed to think that their suffering was a good reason to doubt their faith. The writer wants them to know that divine discipline is an evidence of sonship. Fathers discipline their children, because they are their children, and because they love them. When God chastens or disciplines us, it is evidence of His love for us.
God does forgive our sins when we repent of them and confess them to Him. But this does not mean that there are no painful consequences for our sins. David sinned greatly by taking Uriah’s wife (Bathsheba), and then having Uriah killed. David confessed, and God forgave him of his sins, but this did not prevent God from causing David and the entire nation from suffering some of the consequences of David’s sin:
13 Then David exclaimed to Nathan, "I have sinned against the Lord!" Nathan replied to David, "Yes, and the Lord has forgiven your sin. You are not going to die. 14 Nonetheless, because you have treated the Lord with such contempt in this matter, the son who will be born to you will certainly die." The NET Bible
Sin has consequences, even when we repent and are forgiven for those sins.
Whether we call the consequences of sin "punishment" or "chastening" the bottom line is that God brings about painful consequences, to discipline us, so that we will turn from our sin to Him.