What just happened?

This guy and I have been friends for years. Towards the last 2 years he got super flirty. I didn't want to cross that threshold but he kept on pushing it. I gave in regrettably. We sexted a few times but always went back to normal conversations afterwards. Except last time. He kept saying how bad he wanted to kiss me and look into my eyes etc.. it was intense.
3 days later he tells me he has a g. f and he can't flirt with me anymore because it isn't fair to her. (Didn't even know he had a g. f, but apparently they've been together a year.. so right when he pursued me. He was with her) so I said no problem and unfriended him on everything.
Am I wrong for doing that? And why tf would he do that? I just feel like 5 years were wasted
What just happened?
Post Opinion