Although they are rare, there are cases where newborns have genitalia which are not well-formed as either male or female, and there have been cases where a doctor has marked as a "girl" an infant who in fact was not only genetically XY but in fact had testes. While I do not doubt that 99.44% of "sex change" operations are nothing more than genital mutilations which serve no useful purpose, there have been and no doubt will be some cases which are not so clear-cut (though I would expect genetic testing and sonography would make these less likely).
How would you propose the state should deal with this?
Additionally, if a court in any state recognizes that a person has changed sex, absent federal legislation to the contrary, wouldn't all states be bound to recognize same?