We don’t know. If we knew what causes atypical gender/sex identity development, we might have a more certain answer of that question, but we don’t. What we do know, however is that while genitals may be an (fairly) accurate proxy natal sex, they do not define sex/ gender identity.
there are young children who understand themselves to be female/ a girl , for example, who have a penis. They do not consider their penis to be contradictory to their understanding of themselves as female.
Genitals are also not significant in gender identity development in gender-typical children by the way. Most children have objective awareness about their physical bodies much earlier than they have a gender/ sex identity . Children as young as 1 are expected to be able to point to and label body parts, like their nose, for example.
My daughter (natal female before anyone freaks out) has a very strong sense of self as female/ a girl. She talks about it a lot. Never in the context of having a vulva. She knows she has a vulva and can label it. she’s really only interested in talking about her vulva as part of conversations about toileting, hygiene or health (eg I need to wipe my vulva). She talks about boys in her class, she doesn’t talk about their (or other) penises. I find all of this entirely appropriate and normal for her age (4),