Jesus was being tested (somewhat unfairly) by the teachers of the law.
They brought a woman caught in the act of adultery. They weren’t really interested in justice, or any kind of punishment for her (or else they would have brought the man, too). They only wanted to see if Jesus would recommend her stoning, and validate their own interpretation of the law, or if he would say something else, giving them more ammunition in their case against him as a blasphemer and religious rebel.
Rather than alienate the legalists by recommending leniency, or alienating opponents to the death penalty, he challenged her accusers to look in their own hearts. Yes, in many ways telling them not to judge her sin while they themselves were imperfect.
The most telling aspect of this, though, is the dialogue between him and the woman after everyone has left. He asks her where everyone has gone, and has no one remained to condemn her. She replies no one. And he tells her that he does not condemn her either. But then he tells her to leave her life of sin.
The big difference, it seems to me, is not that Jesus doesn’t recognize the fact that she sinned, but that he does not judge and condemn her for it.
Hope this helps.