I've always seen this as a matter of biology. Sex, gender, and sexuality are separate and unique components. Sex is your chromosome composition, mostly XX (female) and XY (male). However, it's possible to be XXX, XXY, XYY, XXXX, XYXY,or X due to non-disjunction mutations during meiosis. Next, gender is usually defined by genitals and secondary sexual characteristics like breasts. Again, this isn't always as simple as "boy" or "girl", as certain mutations can case an individual who is XY to develop as a female (technically our "default" gender developmentally). Finally, sexuality has a heavy basis in pheromones. Although we're not as sensitive to them as other animals, pheromones still have a huge impact on sexual arousal. There have even been experiments where heterosexual males have shown an arousal response to male pheromones.
TLDR: It's mostly biological.