Hello, ontheD.
I'll describe to you how I used to behave and 'why' and why and how I changed in the conscious level.
I think it all starts with all of us being men. As being a man, you are aware that we're more, or maybe more intense, when it comes to sexual desires and actions if compared to women. We usually are simpler to get, and more straight to the point. There's less storytelling, less romanticism, less 'bs' and more jump to action. That said, the way I used to see a gay friend or acquaintance was based on these feelings, that one would not refrain oneself from using our closeness to transform into a sexual approach, similar to what might happen with a friendship with a woman, only that the initiative would come from the gay guy. So, hugging, at least for me, is a very powerful social tool, an act of care and love, and, at some point but not the most common, of sex. While hugging, you're giving yourself to that person, showing your back to them, getting into a vulnerable position, getting into another person's personal space, and having that same person into yours. I think these characteristics are telling on why some deny a gay man a casual hug. For subjects and chat, it probably revolves around the fact that they don't see a point on talking about girls around you; you can see in two ways: the one you've chosen, that the don't want to talk it about you because they're excluding you from their conversation; or, they don't want to exclude you by talking about something you're not interested, but doesn't know exactly what to talk about then. I used to behave like this, and the reasons are somewhat aligned to what I have written. I'm not an expansive person and I detest people invading my personal space. And to be fair, the smaller, but very vocal and exuberant, fare of gay people here are all but demure, and are constantly tied to obscene sexual behaviour – like peacocks amidst ravens. And that trait lingers in our minds as a red flag.
My choice as to try and not be like that — because I really didn't want to generalize having few gay friends whom I liked, and they have all respected me—, started when one of them sort of turned me into his confidant, because I'm a good listener. Actually, him and his boyfriend. And he told me that it was very difficult for them to find true straight friends, or people in general who were not interested on them sexually or with other intensions, as to take advantage from their jobs to get discounts or something very shallow. They wouldn't get many visits if not from other gay friends or straight couples. And then I simply decided that: asked if it was ok for me to sleep over their place, watch movies, eat popcorn and train at their gym (they were both very similar to my physique, but one was 10cm taller, the other 10cm shorter). They also detested effeminate men, specially when they hit them. They have been called homophobes for that. So, back to their place, it all went normal and smooth. My comparison was as if I was visiting a straight couple. I slept well in the guest room. Nothing 'odd' happened whatsoever. They asked me some questions about my manhood out of curiosity, about possible difficulties in my daily routine and we chattered about a lot of stuff. The bantered between the two of them like a couple would, and that was that. It was enough for me to not get wary and defensive when it comes to people we know and trust. And it serves to women too. I don't want someone I cannot feel safe and trust beside me.
Now, what I think you should do, as an advice. I prefer learning what's happening around me. Sometimes we treat people in a certain way meaning no harm, but because we don't know how to behave without hurting. It's a troublesome philosophy, because we are ourselves too, and it's really annoying or stressing to address all whims and speculations and expectations. If we start doing that, we get crazy, depressed. We need to be ourselves too. So, I prefer when people come clean about that sort of thing, as I prefer doing so as well. Ask them directly, don't speculate here, and see for yourself. Tell how you feel, tell them that they're safe — you see, as long as they perceive you as a person who can use a hug to get a hard on, or get hard if you guys use the urinals, or that you stare if you see them shirtless, that you're going to hit on them when you're alone, these behaviours might continue. MIGHT. I do not know these people, don't know you. So, first things first. Find out by asking the source. We can't do much with only few lines of descriptions or an event of your life.
Stay safe yourself.