I think a boy who says he is a girl is usually rejecting his father, or at least denying his father's masculinity. Often the boy's mother is woke and has an underlying hatred of men due to her own psychological issues, and she usually approves of, and even encourages, the transitioning.
I can say with confidence that this applies to the one case I know personally (who is what people call a "trans woman", but I refuse to call him a woman when he's not). I suspect that it also applies to Elon Musk's transitioning son, from what I've read.
Masculinity is not the problem, it's the lack of it. A boy who says he's a girl didn't grow up around men.