Answer: This is an issue that has confused many people. On one hand, we are commanded by the Lord Jesus, “Do not judge, or you too will be judged” (Matthew 7:1). On the other hand, the Bible also exhorts us to beware of evildoers and false prophets and to avoid those who practice all kinds of evil. How are we to discern who these people are if we do not make some kind of judgment about them?
Followers of Christ (Christians) are often accused of "judging" whenever they speak out against a sinful activity. However, that is not the meaning of the Scripture verses that state, "Do not judge." There is a righteous kind of judgment we are supposed to exercise—with careful discernment (John 7:24). When Jesus told us not to judge (Matthew 7:1), He was telling us not to judge hypocritically. Matthew 7:2-5 declares, "For in the same way you judge others, you will be judged, and with the measure you use, it will be measured to you. Why do you look at the speck of sawdust in your brother's eye and pay no attention to the plank in your own eye? How can you say to your brother, ‘Let me take the speck out of your eye’ when all the time there is a plank in your own eye? You hypocrite, first take the plank out of your own eye, and then you will see clearly to remove the speck from your brother's eye." What Jesus was condemning here was hypocritical, self-righteous judgments of others.
In Matthew 7:2-5, Jesus warns against judging someone else for his sin when you yourself are sinning even worse. That is the kind of judging Jesus commanded us not to do. If a believer sees another believer sinning, it is his duty as a follower of Christ to lovingly and respectfully confront the person with his sin (Matthew 18:15-17). This is not judging, but rather pointing out the truth in hope—and with the ultimate goal—of bringing repentance in the other person (James 5:20) and restoration to the fellowship. We are to speak the truth in love (Ephesians 4:15). We are to proclaim what God's Word says about sin. 2 Timothy 4:2 instructs us, "Preach the Word; be prepared in season and out of season; correct, rebuke and encourage — with great patience and careful instruction." We are to "judge" sin, but always with the goal of presenting the solution for sin and its consequences—the Lord Jesus Christ (John 14:6).
(Source of info: gotquestions.org)