Why are men so confusing?

I had a male friend and we kicked off well until he found out that i liked him and he started to be hot and cold, and i did not understand why he was doing that. So we talked and worked things out and we became friends again, and everything was normal until he started giving me weird looks when ever i would hug my other male friends and he would include himself in conversation i had with my male classmates but i never understood why did all of that and why he would stare at me or side eye me most of the time when im seen with male friends of mine. It got a bit worse when i ended things because of his toxic ways
He was staring at me a lot, whispering my name in class and saying nasty things about me but i would never catch him doing that with other girls but would he do it with me when he was the one who said he did not like me like that, why would he get mad when im hanging out with my male bestfriend Aidan in front of him or even hugging my male bestie
Im confused i dont know what to do.
Why are men so confusing?
Post Opinion