It’s a choice, like most things we do in life.
If being gay were a gene, it would be a self-extincting trait because being gay by definition means no reproduction. If you don’t reproduce, your traits perish.
One of my best friends had a son who from his early childhood wanted to play with the girls, with dolls, none of the usual boy stuff. As a young man he tried with various women but nothing “took”. Finally he admitted he was gay and his mother said she always knew he was different. She also has a normal son.
The gays I’ve known all said they were born that way. Since I was born straight this is something I can understand....sort of.