Seems like it tends to have to do with one or more of:
* their religious authority is their main source of information, as is backwards and homophobic, due to misreadings of religious doctrine which seems to condemn homosexuality as if it were a crime, hence a choice
* their childhood community had the idea of homosexuality as a tabboo/bad thing and since children don’t tend to be sexual at first, and some cultural conversations have it as a crime and/or choice, that idea is picked up on
* they are themselves a bit (or even more than a bit) queer on the non-binary sexuality scale (as most people are not utterly hetero, even if they don’t realize it since our culture tends to want to firmly label things), and/or unsure (again, especially as children), and are afraid of the terrible social stigmas and social (and violent) consequences of being homosexual, their ego greatly prefers the idea that it is a choice they can make to avoid that danger (i.e. it is terrifying to know that your family may abandon you, you may be a social outcast, attacked, etc).
* other variations on similar ideas to the above