It's biology. A small minority of babies have the brains of the opposite sex.
The right thing to do is for the mom and the dad of the transgender child to allow them to be who they are at a very young age.
If a little boy wants to wear a pink dress, play with dolls, and be a princess for Halloween, that doesn't always necessarily mean that he is a girl, but its a likely indicator that he will be at least gay or gender fluid, and there's a good chance that the child is actually female in the brain and if thats the case, that child's mental health depends on her being able to be who she is.
Cross dressers are usually heterosexual.