These verses are alongside each other. For a reason.
Matthew 7
19 Every tree that does not bear good fruit is cut down and thrown into the fire. 20 Therefore by their fruits you will know them.
21 “Not everyone who says to Me, ‘Lord, Lord,’ shall enter the kingdom of heaven, but he who does...