Humans are communal. As much as some of us want to be hermits and loners, we by nature want and need contact with other humans. We gravitate to certain individuals who share common likes and dislikes. If we are lucky we find those who we can attach too for a long term friendship.
Sometimes we find that other person was not who we thought they were the entire time we were friends. The longer the relationship the worse the hurt of rejection. That rejection makes us shy away from making new friends.
The key is to accept that other humans are faulty, let that bad relationship go and move on. Be cautious but don’t let that hurtful experience shut you off from others.
You will miss amazing people and friendships if you close your heart.