Actually, Sex is assigned at conception, depending on whether or not the sperm cell fertilizing the egg cell carries an X chromosome or a Y chromosome. A doctor or midwife doesn't subjectively decide to anoint a newborn as Male or Female, depending upon their mood or their political beliefs.
The external genitalia are physical manifestations of the presence of the X or Y chromosome in the infant's DNA. In most cases, the biological Sex of a newborn is unambiguous. A "person's internal sense of who they are" pertains to gender identification. No qualified medical practitioner is going to say 'Well, I see testicles and a penis, but I won't be able to decide the Sex if this child until after they decide what they want to be'. No amount of wishful thinking can turn one's X chromosomes into Ys.
Essentially, all trans individuals are wishful thinkers. They aspire to be different from what they are. Surgery, makeup, wigs and lipstick can make anyone appear to be something that they are not, but a change of appearance is only that; an illusion, a delusion, or both.