If you want to get very precise, doctors don't observe sex at birth either.
They observe external genitalia and, based on this observation, the child is assigned M or F in official documents.
There is no assignment. Doctors observe a male or female child based on external genitalia and record their observation.
That method is imperfect. Depending on how you define sex - the external genitalia don't always match other sex characteristics (e.g., chromosomes, hormones).
It might be imperfect, but that method is correct with at least 99.99% accuracy. And chromosomes are not the end point of sex differentiation but the beginning. A female-bodied child with XY chromosomes is female, a male-bodied child with XX chromosomes is male.
Also, hormones do not determine sex. Both sexes produce all types of androgens and estrogens, at varying levels throughout their lifespan, with the most noticeable effects of masculinising androgens and reminiscing estrogens experienced in puberty. Female-bodied individuals with high testosterone levels (for instance those suffering PCOS) are still female and male-bodied individuals with high oestrogen levels are still male (for instance those suffering prostate cancer).
Below I've linked to an interesting Twitter thread where Dr Emma Hilton explains her findings from looking at karyotype studies in newborns which recorded the phenotypes of these babies. She found that of almost 65,000 newborns, 99.99% had a male or female kartotype in accordance with their phenotype. 1 newborn had ambiguous genitalia.
mobile.twitter.com/FondOfBeetles/status/1111352888385769472
Furthermore and just FYI, in the rare cases where genitalia are ambiguous, sex is not assigned at birth. Specialist doctors are called in for a series of tests in these babies. In the UK, that's approximately 130 babies each year. These tests allow doctors to determine the sex of most of these newborns. They are inconclusive only in a small number, and those are the only newborns who are ever assigned a sex, in consultation between the parents and the specialist doctors. That amounts to 0.001% of newborns each year.
Making it entirely incorrect to speak of doctors routinely assigning a sex to all newborns. And appropriating the language used for and by people with extremely rare and often very complicated and difficult medical histories is reprehensible.
(The percentage I quote stems from the submission to the Scottish Census consultation by dsdfamilies, an organisation set up by and for people with and parents of children with Differences in Sex Development (DSDs) to better support their needs in Scotland.)