Some say birth order has some influence on it. If you are the youngest of many male siblings then by time you are born , the mother has much lower levels of testosterone in the womb. The later you are, the lest testosterone you get, the lest testosterone a male has, the more likely they are to be gay. There is no correlation seen with women and birth order however.
Some say it's surroundings. "The exotic becomes erotic" they say say. If a young boy were to be constantly surrounded by woman at a very young age, and continue that trend through puberty and adolescence, then they will more than likely see their female friends as friends, and not lovers. This would confuse the young mind to thinking that a male should be his romantic partner. A good example of this in a different context, though not exactly the same, is how some American men are more attracted to Asian, Black, or Latina women. Women of another race are exotic, they are something exciting. Thus we are attracted to them.
And some people say it's just a flat out chemical imbalance in the brain.