I can think of all sorts of hypotheses for how gay genes, or at least genes that increase the inclination to be gay, could be spread. It may well be the case that in our evolutionary past, such genes manifested differently than how they do now. In fact, the idea that someone is either gay and is exclusively attracted to the same sex, or straight and exclusively attracted to the opposite sex, is a rather modern idea that would have been unusual even as recently as the Victorian Era and would seem very odd to many of the people of antiquity. How the gay tendency genes affected stone aged people with the radically different lifestyles and social structures they had might be different from how they affect modern people.
It could be the case that if you have two caveman brothers in a tribe, who both share the similar DNA, that the family or even the tribal DNA gets passed along better if one of those brothers is gay and one and straight rather than both being straight. The straight one just gets twice the girls, as harems were a big thing back then. The number of children a tribe can have is limited by the females anyway, who seem to be less affected by gay genes than males. If a few guys in the tribe are having sex with each other, the tribe as a whole can still reproduce just as much as long as the women are having babies. Those gay genes might just piggyback on the straight or bi siblings, maybe they are even carried by relatives of the opposite sex.
These are just some random musing by me, I really don’t know. Though ultimately, just about everything about us is going to have some genetic component, even those traits which we imagine are purely environmental. Humans are a product of both genes and environment, you can’t remove the influence of either one.