I’m honestly so confused

I’m so sorry about the length of this.

There was a guy I was dating some time ago (aug 20 to jan 21), when we were dating he treated me like I was his girl/ his everything etc. He ended things and never said why so obviously I was hurt by this situation because I felt like he was my person if that makes sense. We didn’t speak again till my bday in October (8 months), when he apologised, told me I didn’t deserve that, explained how he felt that I was putting him under pressure to make me his gf (which didn’t make sense because we were long distance and only dating for 5 months), he was going through something, didn’t trust girls (which had nothing to do with me). Anyway my cousins birthday was a few days ago (I met him through my cousin) and he didn’t even talk to me at all except when he said hi asked how each other was etc. At the end of the night we were talking and flirting. I told him that I missed him (which I actually meant) and he said the same thing (I told him not to say anything like that if he didn’t mean it). We ended up having sex again. We were even cool after. He walked me to the cab, made sure I was okay when I got home and everything, calling me his “bestie”. The next day I found out that he was flirting with my friend and telling her he was attracted to her basically (some of this was actually done in front of me but I didn’t hear because of the music) and one of his friends also referred to me as his “fuck buddy” (I don’t think you talk about marriage, kids and morals with your fuck buddy) so I confronted him and he said it shouldn’t matter because I was being overly friendly with his friends (which wasn’t true at all, I told 2 of them that it couldn’t happen simply because I respected him). One of his friends told him that he kissed me (which also wasn’t true, it was cleared up later that he didn’t). He said he didn’t care, but he clearly brought that up to justify his actions. When I confronted him he was just being a bastard (“believe what you want to”, “what I do shouldn’t matter to you” “you’re talking like you still have feelings” and other things of that nature, just thinking about it now he was gaslighting me). It hurt me that he did that I won’t lie. I’m not completely healed from the situation because it’s like the wound keeps getting reopened. He’s so nice when we talk on socials but when he sees me he’s cold towards me. I’m just confused because why would he do that knowing that at one point he treated me like a Queen and he still says he has love for me. I didn’t nothing bad to him (he still says it till this day) if anything I loved him and put my all into the relationship. I don’t want him completely out of my life but that really hurt. Am I just being dumb?