Why would a guy be flirty with me and show he likes me but say he likes someone else?

This guy I’m friends with keeps complimenting me, deliberately annoying me trying to be funny, always calls me love or Bub, sends me snaps of him dancing or being goofy or funny tik toks all the time cause he’s trying to make me laugh, calls me at midnight some nights cause he just wants to talk and when I’m with him sometimes I catch him staring at me with a goofy little smirk.
But he recently said to me how he has feelings for someone that came all of a sudden and hit him like a truck. He never said who he just said “someone” that’s all I got I didn’t pry cause i felt that if he wanted me to know who he’d tell me but even tho he’s saying he has feelings for someone he’s still got that goofy little smirk everytime he looks at me and showers me with compliments and looks after me and teases me and it seems he always wants my attention. Everytime he gets drunk I get a phone call no matter the time or day just to babble drunken nonsense to me and ask me a million questions about myself. Just a little confused as to where his heads at

Why would a guy be flirty with me and show he likes me but say he likes someone else?
Post Opinion