There's no gay gene, it either comes from a social, hormonal or developmental factor or a combination.
A big cause is prenatal hormones, too much estrogen exposure to a male fetus or testosterone to a female fetus is heavily linked to homosexuality. Faulty sperm might cause it too. There's a thing called fraternal birth order where the more sons a woman gives birth to the likely the youngest will be feminine or gay. This is because the female body gets more used to the testosterone surge that occurs while carrying a male fetus, and develops a resistance to it. The testosterone resistant pregnant female's body increases estrogen.
Anyone planning on having a lot of sons need to be cautious, I'm not sure whether there's ways to increase testosterone on a pregnant woman or whether that'll be healthy. Maybe marry a woman with PCOS but then you'd have to be worried about your daughters. A healthy diet might prevent it tho.
The biggest reason for homosexuality must be social though, LGBT people are much more likely to have abusive childhoods or molestation. And now its a trend to be gay, in the past only like 0.6% identified as gay and now Zoomers are like 40% gay, there's an agenda.