I think your idea that he wanted a longterm relationship but kept sabotaging it needs to be looked at. You know who do that? For one, narcissists. They are never 'actually' happy worh what they have so they always look for something else. For the bigger better. For the extra add on.
Now you haven't given us enough info to say that's his deal of course. But, just worth noting.
Either way it sounds like he's maybe been telling you he wants one thing (commitment) and his actions have shown something else. Because people who REALLY want committed relationships (with you) do not keep sabbotaging them. They just don't.
And I think it might be worth being honest woth yourself there. Because otherwise you are pitying him like he's some little lost child who just messed up. He's not. He's clearly consistently been a douchebag.
And I think recognising that should probably be your first step. Even if uts painful to come to terms with the fact that he will never choose anyone but himself.
Secondly, give yourself a pat on the back for removing yourself from this whole situation. Just because he is disordered af, doesn't mean he gets to drag you along for the ride.
Good on you for getting out.
Thirdly...cliche but, good tv, ice cream, chocolate, bubble baths and a new haircut or even wardrobe. Maybe a holiday. And time. Lots and lots of time. First love can take a while to get over. Block him on everything. Step away from social media for a while if needed too. And don't think about dating again for at least 6 months. Potentially longer as it seems you might have some unhealthy stuff to work through first (the competing notion that people who love us and want us will still repeatedly hurt us and push us away).