In rats, exposure to prenatal androgens will make a female rat behave just like a male. As an adult, she will fight with males and mount other females. Studies have also shown that if a pregnant rat is subjected to extreme stress during pregnancy, this causes release of stress hormones into the blood which can block the effects of testosterone in the developing male rats brain. The result is that the male rat is physically a normal male, but exhibits homosexual behavior as an adult. He is attracted to other males, and assumes the female position in the presence of other male rats.
Can this also happen in humans? Intriguing evidence comes from a study of men born in Germany during the highly stressful period of WWII compared to men born either before or after WWII. The study found a much higher rate of homosexuality among men born during WWII than in men born either before or after the war, supporting this idea. However, this cannot explain all instances of male homosexuality, because most mothers of homosexuals do not report unusual stress during pregnancy. So other factors must be involved.