The biological definition of the two sexes is that males are the organisms that produce the mobile gametes, while females produce the non-mobile gametes. The same definition can then be applied to any organism with two distinct gametes, not just animals. Even in plants, the male plant (or male part of the plant) produces the pollen that is mobile (sometimes because of a carrier) that gets transferred to the female plant (or female part of the plant).
The medical field defines the two sexes the same way, but then also uses the terms male and female to refer to gender, which is not the same as sex. Gender is more of a psychosocial construct. So, for example, someone who is biologically of the male sex may have an operation, take hormones, or wear clothing to take on the outward physical characteristics of a female, and may wish to be referred to as female gendered.