and can’t explain why he did this
Oh God. That old chestnut 😂 Pathetic.
I can tell you why. He's an opportunist who doesn't take monogamy seriously....or rather, he expects you to be faithful, whilst he has his cake whenever there's an opportunity to taste something different.
keeps saying he doesn’t deserve me and gets upset
It doesn't mean much I'm afraid. Some people do really bad things and they will cry, scream and beg to be forgiven. Their distress might actually be genuine, but that isn't the long-term, real them. They feel and behave like that because they're having a panic - it's probably quite convenient and nice to have you in their life, and they don't want to lose that, but that doesn't mean they will treat you well. Once the dust settles, they sooner or later return to their old ways.
Also, it's worth keeping in mind that a lot of men don't leave their partners. They just slowly become shittier partners, stretching the absolute limits of what they can get away with to the point she accepts the burden and emotional responsibility of ending the relationship. They would rather make you angry and give you longterm trust issues than have to deal with a crying woman. It could be that now you're getting closer to actually setting down together, he's trying to find an exit and this is his horrible way of making you break up with you, even if he insists that's not what he wants. Women do it too, but I'm afraid men will coast along for YEARS in a relationship with a woman that they know isn't THE One, simply because it's easier and their female partner is nice to them, and provides regular sex.
Don't waste more precious years of your youth on him.