There are many definitions of sex. Sex is an activity, a commodity, and part of who we are. For better or worse, the first definition most people learn is the physical definition of sex, where sex is used to define all people as either men or women.
This definition, not to be confused with definitions of gender, is one that is applied to our bodies either before we are born or when we are born. If our sex is defined at birth, it happens when the person assisting in the birth looks at our body; if they see something that looks like a penis, they say "it's a boy," and if they see something that looks like a vulva, they say, "it's a girl." Sometimes this announcement is made before we're born, during an ultrasound examination, when the technician views the baby, and if they see something that looks like a penis, they say "you're having a boy;" if they don't, it's "you're having a girl."
It's important to note that, even though this definition of sex is sometimes called a genetic definition, our genes are almost never examined. Sex at, or before, birth is rarely determined by a blood test or anything other than a visual assessment. Someone (a doctor, a nurse, a midwife, or whomever is assisting with the birth) looks at us and tells us what we are. For this reason, some people describe this definition of sex as physical sex, or as a definition of sex based on reproductive organs.
Of course, not all of our bodies look the same when we're born, and even though they only give us two options - man or woman - some of us are born with bodies that don't fit that binary. In these cases, even though there may be nothing at all wrong with the way our infant bodies work, an infant may be labelled as intersex, and that infant's body can be immediately assumed to be in trouble, and in need of fixing. This incorrect (and dangerous) assumption is slowly changing over time, although it isn't changing everywhere. Despite the fact that, based on visual assessment, there are more than two options of an infant's sex, the medical community and the general public still think of sex as being defined as either man or woman.
Another way that sex is determined is through our genes, or DNA, where doctors will identify which sex chromosomes we have. With this definition, we are once again forced into one of two categories. If a baby is born with two X chromosomes, it is called "female," and if a baby is born with one X and one Y chromosome, it is identified as male. What's particularly odd about this is that we have known for some time that these aren't the only two options.
Some people are born with two X's and a Y, some people are born with one X and two Y's, and some people are born with only one X. All of these people are identified as having "chromosomal abnormalities". Because our chromosomes are not routinely examined at birth, the first sex label we get is a physical one. If at some point in the future our bodies aren't developing in a way that matches what we were told our sex was, tests may be performed to determine our genetic or biological sex.
Slowly but surely. the medical and mental health professions are acknowledging some things that regular people have known forever: sex is not a simple binary option, we don't all fit neatly into one of two categories, our chromosomes may or may not match what our bodies are expected to look like, and neither may match how we feel about ourselves. People can also live happy and healthy lives if they are supported to understand how these definitions of sex relate to their own understanding of their sex.