homosexuality is genetic.In males we have one X and Y chromosome.X comes from female coz female has XX chromosome and Y comes from male coz males have XY chromosome.So gender of child depends on X or Y chromosome coming from father. Y is actually X with lower right part from X absent.SO Y chromosome has only lower left part.So sometimes if lower left part of Y chromosome is recessive ( generally its dominating one ) i.e not dominating one then corresponding part of X chromosome from XY dominates and the person though born as male has got female instincts.
If the behavour is due to environment or a brain problem or hormonal imbalance then it can be treated.