I believe that there are four principal factors which individually or collectively contribute to SSA. The first factor is the "inability of the child to identify with the gender of the same-sex parent." This comes about when the child (and later, the adolescent) has difficulty connecting with the same-sex parent, whom he or she regards as distant or hostile. In her foundational study, Psychogenesis and the Very Early Development of Gender Identity, Elizabeth Moberly explains the child's need to connect, indeed, to identify with the same-sex parent. To achieve masculinity, a little boy needs to communicate (and identify) with a father; a little girl, growing in femininity, likewise needs a mother.
The second factor Moberly identifies is "an over-weaning relationship with the opposite-sex parent." I knew the mother of a large family whose husband was working several jobs to support the family, and the mother meanwhile formed an excessively close relationship with the youngest boy. He was not near in age to his older male siblings, and the result was that the mother confided in her youngest son more than she confided in her husband. Unfortunately, she tended to speak ill of her husband to her son; in a sense, she was making her son into a substitute for her husband. The young boy began to alienate himself from his father as a result. Of course there were other factors: he related poorly to his older brothers, for instance. As an adolescent, this young man found himself having sexual fantasies about other young men, and even about older men. Although the boy did not understand the significance of these attractions, it is clear that he was looking for a closer relationship with his father.
A third major factor in the development of SSA is an "inability to identify with peers of the same sex during childhood and adolescence." This discomfort with other males (or other females, in the case of women with SSA) may or may not last past adolescence. A common example here would be the young boy who, lacking confidence in himself because of his poor links to his father (or older brothers), avoids teams and team sports, prefers young girls as his companions, and feels threatened by competition with other boys. This leads him in adolescence to fantasize close relationships with this or that particular male. Another example is a young lady who regarded her mother as weak because she always gave in to her domineering father. The young lady told herself that she was going to be strong like her father, and she began to think in a masculine way. She admired his aggressiveness; it is not surprising that as an adolescent she had fantasies of other women.
The fourth principal factor contributing to SSA is "emotional abuse (including neglect) or sexual trauma" - suffering that often go unacknowledged or unrecognized. Unintended emotional damage may be done, for instance, by a father who, while demonstratively proud of an older, athletic son, neglects a younger son who is uninterested in sports: the younger boy easily feels inferior and unsure of his masculinity. Likewise, a girl whose parents wanted a baby boy (for example), may perceive their disappointment or even be treated as if she were a little boy - which naturally undermines her sense of who she is. Witnessing domestic or sexual violence, or being sexually abused oneself, may also have very grave effects on a child's sense of sexual identity.
A note must be made here on the question of possible biological or genetic factors in the development of same-sex attraction. Many researchers have proposed that the origins of SSA lie in brain structures (Simon LeVay, Laura Allen and Robert Gorski); genetics (Dean Hamer, J.M. Bailey and R Pillard), or hormones (H. Meyer-Bahlburg). These studies are always oversimplified by the media and have not been replicated in the scientific community. To date, there are absolutely no conclusive studies that link same-sex attraction to genetics. Despite this reality, people still tend to put their hopes in such studies rather than explore the complicated world of psychosexuality.
(Source: Same Sex Attraction: Catholic Teaching and Pastoral Practice by Fr. John F. Harvey, OSFS)