The terms male and female describe reproductive organs. Yes, there are males and females with rare disorders. Some of those disorders can be handled with treatments now. No one is perfect, but we shouldn’t determine a person’s sex (in a legal sense) based on some abnormalities he or she may have.
If a man undergoes surgery to look like a woman, legal documents such as a driver’s license should still list his sex as male. If he wants to compete in sports, he should have to compete in men’s sports. If convicted of a crime, he should be put in the men’s prison. The law should deny marrying him to another man.
If we open our laws to allowing people to determine their sex according to how they feel, they could switch back and forth.
The only people whom I would suggest should be offered the 'choice' would be those people who possess some congenital physical characteristics that would with 99+% reliability identify them as males and other congenital characteristics which would with 99+% reliability identify them as females.
For example, I would suggest that anyone with an XY genotype who has not previously registered as a female should be allowed to register as a male; anyone born with a vagina who has not registered as a male should be allowed to register as a female. Someone who has an XY genotype and yet is born with a vagina should get a one-time chance to officially register as one or the other after turning 18.