I've got to think it's primarily a "born that way" thing, though perhaps environment (what you experienced, how you were raised/parented, who you hung around, what you saw, etc.) might play some part in determining your sexuality as well. In other words, I wouldn't be surprised if there are some people whose biological makeup dictates that no matter what happens to them in life and their experiences, they WILL be gay when they grow up. And perhaps there are other gay people who have a strong genetic component that made it POSSIBLE but not CERTAIN for them to end up gay when they grew up, but environmental factors (life experiences) might've ended up tipping the balance one way or the other.
But that's all just my hunch. And, once we get into including the subject of those who are bisexual in the discussion, it gets even more muddy.
On a related note, a couple years ago I met (and ended up dating for quite some time) a very hot "lesbian." She had never slept (or sexually fooled around with) a man before and fully thought of herself as being a lesbian. (She was 31 at the time). Suffice it so say, one thing led to another and we became close, then closer. We would make out, and she would be into it. I'd put my hand on her nether regions and play with her and she would be soaking, soaking wet. I'd get her off orally or otherwise and she'd have major orgasms. All this time (first few months of our "relationship") I would rib her and say things like "You are one sorry excuse for a lesbian!" And she would reply that yes, she was indeed a lesbian, and that merely enjoying being touched by someone, etc. did not make her straight or bi, but that she "identified" as being a lesbian and "that's what matters."
Yeah, fine, define it whichever way makes you feel most comfy but, as I tried to explain to her, she is not fully "lesbian" the way I am fully straight. She fools around with a guy and gets soaking wet and has intense orgasms. If I were ever, God forbid (PURELY hypothetically, here) to do ANY such thing with a guy, my dick would shrivel up, my nuts would retract inside my body, I would vomit, and then I'd probably reflexively punch the other guy in the face. As opposed a guy who was fully gay (or bi), whose dick would stand up in such a situation.
And yes, in answer to everyone's burning question, we did indeed eventually seal the deal, and had a relationship that went on for about a year and a half. (Eventually she pissed me off for totally unrelated reasons -- got on my nerves -- and I told her to lose my number. She's since moved away and, as far as I've heard, is back to petting kitty).
Interestingly, she grew up in a household where her father was a physically abusive alcoholic. Not sexually abusive, but it sounds like she and her sister often got beaten up pretty roughly. (No, the sister is not a lesbian). I have a hard time believing that this abuse at the hands of what was the only meaningful male figure in her life, ever, didn't played into her sexual orientation to some degree. She's majorly attracted to women and always will be, make no mistake (I'd say her "compass" is probably 80/20 in favor of pointing towards women), but technically she's bi, and I would think she could certainly end up in a lifelong relationship with either a woman or a man if she met the right one, BUT, in order for that to be a man she would have to allow herself to be in a POSITION in which she was willing to meet a man and let it develop into a romantic context. She never did that for the first 31 years of her life.