I did NOT know about the SRY gene, nor the fact that it could move over to an X chromosome!
I'll add one more wrinkle: genetic mosaicism or chimerism, particularly due to a twin absorbed early in gestation. Yes, it happens; sometimes called vanishing twin syndrome. Approximately 7% to 36% of IVF pregnancies involving multiples are diagnosed with VTS; I don't know if they regularly lead to chimerism.
Chimerism means that some of a person's cells can be XX and others XY. So a person might have gonads formed from XX cells, but (some) muscles from XY cells. Or, the same chromosomes can be expressed differently in different parts of the body.
I'm not sure which of these genetic irregularities cause hermaphrodite AKA intersex babies, but intersex is a real thing and "look between the legs" doesn't always answer the question.
According to Dr. Anne Fausto-Sterling, a recognized expert in this field of study, 1-1/2 to 2% of all births do not fall strictly within the tight definition of all-male or all-female, even if the child looks "normal." In reaching her numbers, Dr. Fausto-Sterling counted all incidents of intersexuality, from mild to extreme. The incidence of children with mixed genitalia is pegged at 1 in 2,000 to 1 in 3,000, or 0.033 to 0.05 percent of all births.