Warning: Long response.
Before we can ask why people are gay, I think we first have to ask what being gay actually means.
Men have been having sex with men for thousands of years. In some cultures this was accepted had its own set of rules and norms (think Ancient Athens), in others it was taboo, but it's a universal thing.
At the same time, the idea that men who have sex with men are gay, and that men who have sex with women are straight, isn't part of the historical record. That's mostly a modern idea, and comes out of the same scientific boom in the Victorian era that gave us eugenics, phrenology, the idea of female hysteria, Freudian psychoanalysis, and a lot of other things that we don't take very seriously anymore.
Still, some men want to have sex with men, some want to have sex with women; we can't deny that. But even then, there's a lot of fluidity--plenty of men want to have sex with men, but marry women anyway. Some men don't generally want to have sex with men, but still choose to do so when surrounded by other men long enough, in militaries, prisons, boarding schools and monasteries. Almost every day there's another post on here by someone who can't make up his mind whether he's gay or straight.
You could look at this and say a couple of things. You could say "some people are gay, some are straight, and some are bisexual." You could follow the Kinsey scale and say "All people have the capacity to be bisexual, but most prefer men or women to some degree," which seems the most convincing, at least to me.
But then we have a problem--suddenly, being gay isn't something that's off or on; it's instead a modern world for a sliding scale of many feelings and behaviors that different people choose to express in different ways. What's even more difficult is that we don't even have a definition of gay that we can measure.
People can tell you if they think they're gay or not, and people can tell you who they have sex with, but neither of those is scientific. Someone can identify as gay, but only after they've been taught to make that choice. Most men who had sex with men in human history never identified as gay, because the word didn't exist.
You can look at behavior, but that's also unscientific--who you have sex with is a choice, and can reflect social norms, learned behavior or special circumstances as much as it can reflect some innate feeling.
I don't mean to suggest that being gay isn't a real thing. I'm gay, and I'm sure that's more than a choice or a make-believe concept. But at the same time, it's an abstract concept, not a simple natural phenomenon.
I mentioned phrenology earlier, and I think that's a good comparison. A hundred years ago, scientists made maps of the brain, claiming that different spots were responsible for different personality traits. A bump here meant you were argumentative; a bump there meant you were spiritual. It looks like science from a distance--some people really are more spiritual or argumentative than others, and your brain really does affect how you think and behave. But at the same time, we know now that looking for a bump on someone's head to see why someone is argumentative makes no sense, because it's not something that's built into your body so simply.
I expect that in a hundred years, we'll view homosexuality the same way. Looking for some string of genetic code, or checking someone's hormone levels to see why they're gay will seem silly, because our concept of homosexuality (and biology, and psychology) will have grown enough for us to realize we were expecting simple answers to a complicated concept.
Also, I think a lot of people would object to you categorizing being transgender as a birth defect.