Boy XY, girl XX. That’s how it works most of the time. But in every 1/50 to 1/5,000 babies born, there is a DSD, also known as a disorder of sexual development, commonly referred to as being intersex.
XY can be male, or rarely female.
XX can be female, or rarely male.
There are biological conditions that cause sex reversal, pseudohermaphroditism, hormone insenesitivity and hundreds of other conditions where chromosomes don’t decide one’s sex.

In the above diagram, one can see how embryos are born as essentially blank slates, with genes and hormones influencing which structures grow and which recede.
Most non-doctors would have no idea that the male and female sex organs start off the same.
In almost all of us, one primordial fetal structure becomes the penis or the clitoris.
In almost all of us, one primordial structure becomes the scrotum (fusing down the middle) or the labia, depending on a complex cascade of genes and hormones.
But in some, there can be a half-scrotum, half-labia. Or an unfused scrotum, or a penis that has a hole along the bottom, where it didn’t fully fuse. Or streak ovaries that didn’t fully develop. And every other variation in between.
Perhaps even more surprisingly, genes are not THE deciding factor. It’s way more complicated.
The penis can develop in a genetically female XX embryo. A clitoris can develop in a genetically male XY embryo.
That’s as far as I want to go for today into the amazing variations that are considered under the intersex umbrella.
Human sexuality and development is far more complicated than you or I might think. A matter best understood by a clincal geneticist or paediatric endocrinologist, or by an intersex person themselves.
Anyone who reduces it to something simple or just a black-and-white issue of male or female is being just that: simple.