Since nobody has answered, I'll give it my best shot....
How do we know God is punishing us? Honestly, without sounding too karmaic here, we do most of the punishing ourselves. In 1 Samuel, did Saul feel God was punishing him or did he truly understand that it was HIS OWN PUSHING AWAY that caused his possession by evil spirits? King Saul abandoned God's grace, God didn't abandon him. The Scriptures word it a certain way, but it is obvious that Saul left God's protection. Outside that protection is the demonic. Sometimes what you might thing is punishment is God testing you or Satan badgering you. And sometimes it is none of the above, just psychological struggles we all might suffering with and need help navigating through with a therapist of some kind. Depression is a result of the Fall. Is that a punishment?
I try not to look at life in terms of punishments, just thank God for my rewards. If I'm having my boss riding my tail at work (usually true), I don't take it as God's punishment, but just the result of my not being a hiney-kisser and trying to do right by my students and their parents. If I get sick, is that a punishment? Nah, it's called germs and viruses. They happen.
I assume with the "mocks the mockers" comment you're referring to James 4:6 when he references Proverbs 3:34, etc.
"God resists the proud,
But gives grace to the humble."
It means that we have to open our hearts to God. We aren't perfect, but we open our hearts and ADMIT we are the chief of sinners and in desperate need of God's mercy. Without His mercy, we're doomed completely! If we can admit we're weak, pitiful, needy, and show humility, God helps us. If we come to Him with an arrogance and a pride, a feeling that we are already good-to-go like the Pharisees behaved in Jesus's time, how can God work in us?
That is my take.