There are almost definitely both genetic and environmental factors at play in people’s sexuality and gender identification. Lots of studies have been done on this, and the general conclusion is, “It’s complicated, and there isn’t just one cause, but something is happening between all of these factors.”
Here’s a Wikipedia link for the sexual orientation side of things, if you’re interested!