How to stop hurting

Li

Theres a guy we dated, he really liked me at first and put in a lot of effort with me. At one point i noticed that he seemed to have lost interest and then gradually left my life without a care in the world. We spent months together and now he seems to be in a secure relationship with another girl who he met while he was with me. I'm very heartbroken, how can he just switch it up just like that? What did i do wrong? What's wrong with me?