That’s taking what Jesus said in Matthew 7 out of context. What He was saying is don’t be a hypocrite, don’t judge others for unrighteousness if you yourself is unrighteous.
““Do not judge so that you will not be judged. For in the way you judge, you will be judged; and by your standard of measure, it will be measured to you. Why do you look at the speck that is in your brother’s eye, but do not notice the log that is in your own eye? Or how can you say to your brother, ‘Let me take the speck out of your eye,’ and behold, the log is in your own eye? You hypocrite, first take the log out of your own eye, and then you will see clearly to take the speck out of your brother’s eye.”
Matthew 7:1-5 NASB1995
He’s illustrating judging others with taking the speck out of your brother’s eye. He’s not saying not to judge others, He’s saying don’t judge others without judging yourself. Get the beam out of your own eye before you judge others. Right after this He goes on to warn about false prophets and knowing how to identify them. This is another example of judging others by their actions or fruits.
““Beware of the false prophets, who come to you in sheep’s clothing, but inwardly are ravenous wolves. You will know them by their fruits. Grapes are not gathered from thorn bushes nor figs from thistles, are they? So every good tree bears good fruit, but the bad tree bears bad fruit. A good tree cannot produce bad fruit, nor can a bad tree produce good fruit. Every tree that does not bear good fruit is cut down and thrown into the fire. So then, you will know them by their fruits.”