The Greek of Matthew 5:48 can be translated as an imperative "You must be perfect" but it can also be a future "You will be perfect." The Sermon on the Mount is the Manifesto of the Kingdom, Jesus' way of doing things. And the point is that He undertakes to perfect every person who loves the light (John 3:21). And if we look carefully we will see that any spiritual change in a person in the direction of perfect love is because "their deeds have been done in God" (John 3:21). That means all sanctification is by the Spirit and by grace alone (as in 2 Cor.3:18).
It may be necessary to judge others if we want to hire them for a job, function as a magistrate, give grades in a class, decide if some is up to singing a solo. But that kind of judging is the ordinary assigning of consequences in Caesar's world. It is pernicious to judge another person's progress in sanctification (a very quick way to wreck a church congregation).
I like to imagine the Holy Spirit beginning His gracious work in the hearts of a hundred people in a church. And each of them has a hundred faults (as do our children) that will need correcting. But the Spirit alone knows the right sequence of change that will result in the perfection needed for heaven. I experience the Holy Spirit working on my faults number 1, 2, and 3 and I assume the other brothers and sisters should also be making progress in those primary changes. But the Spirit is working on another brother's faults number 34, 35, & 36, and he will not change the brothers's faults 1, 2,and 3 till much later (I have often seen astonishing change in the last week of a person's life). Similarly He is working on a sister's faults 67, 68, and 69, and she will wonder why I am making no progress in those directions.
That is the point of making the very idea of judging in Matthew 7:1-3 totally ridiculous.
Jesus told us to sail right between the rocks of Pharisaism (legalism) on the one hand and the quicksands of Sadduceism (liberalism) on the other (Matthew 16:6). We still have to do that. But we also need to sail right between Calvinism and Arminianism. Some Calvinists say that if we are elect it will be evidenced by our sanctification. As I have demonstrated with the 100 faults example, progress in sanctification is totally impossible to judge in any other brother. Some Arminians say we are responsible for pursuing holiness and perfection according to their prescription. That is an insult to the Holy Spirit who alone can produce the fruit of the Spirit and all other evidences of perfect love in His own way and His own time.
What we have to do is navigate right between the two errors. We never
judge the progress of others in sanctification, not even in our own lives.
And we just look to the Spirit without paying any attention to our own
flesh (or any other person's flesh) as Paul taught clearly in Romans
8:5-8. And when the Spirit does produce some holiness in us,
or pearls of His wisdom, better not brag about what we are doing to the
dogs and pigs who don't know any better (7:6).