The homosexual gene (if it exists) could be recessive, so heterosexuals could carry a "gay" gene and pass it on for generations until they had offspring with another person who was a carrier for the gene. If they both passed on the gay gene, their child would be gay.
Another possibility is that the gay gene requires something else to trigger it, or that homosexuality is caused by a combination of several different genes.