Isn't being perfect like God, as mentioned in Matthew 5:48,
an impossible goal for humans to achieve?

In the Sermon on the Mount, Jesus made firm demands of his disciples.
We are to love our enemies, pray for thoses who persecute us and not think hateful thoughts against anyone.
Theses demands go beyond the requirements of the Ten Commandments. "
Unless your righteousness surpasses that of the Pharisees and the teachers of the law," Jesus said,
"you will certainly not enter the kingdom of heaven"
{Matthew 5:20}
These people kept the law scrupulously, but something more was needed.