When Jesus says that he is referring to false prophets. People who have false teachings. Not how you behave, but what you teach. That's the context of that verse. How do I know this? Well read the verses before it... It is literally talking about false teachers, and what they teach.
You should not judge people on their behavior on whether they are saved or not. Not everyone is on the same part of their walk. Some people are babies in Christ and growing and getting sanctified. Examine yourself! As Paul would say.
Seriously have you even read Matthew 7? Jesus said all of these one after another each building upon one another. He was reiterating on the message of obedience each time.
“"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.”
MATTHEW 7:15-20 NASB
“"Not everyone who says to Me, 'Lord, Lord,' will enter the kingdom of heaven, but he who does the will of My Father who is in heaven will enter. Many will say to Me on that day, 'Lord, Lord, did we not prophesy in Your name, and in Your name cast out demons, and in Your name perform many miracles?' And then I will declare to them, 'I never knew you;
DEPART FROM ME, YOU WHO PRACTICE LAWLESSNESS.'”
MATTHEW 7:21-23 NASB
“"Therefore everyone who hears these words of Mine
and acts on them, may be compared to a wise man who built his house on the rock. And the rain fell, and the floods came, and the winds blew and slammed against that house; and yet it did not fall, for it had been founded on the rock. Everyone who hears these words of Mine
and does not act on them, will be like a foolish man who built his house on the sand. The rain fell, and the floods came, and the winds blew and slammed against that house; and it fell-and great was its fall."”
MATTHEW 7:24-27 NASB