This can occur in many different ways but basically you have a mechanism where one organism borrows some of the genes it uses to produce offspring from another. Originally only one member of the species would have had this ability basically by accident, but over time that trait would turn them into a new species where every member does it and they would functionally be something like [simultaneous hermaphrodites](https://en.wikipedia.org/wiki/Reproductive_system_of_gastropods#Simultaneous_hermaphrodites).
Over the generations at some point you might see an evolution of sexes where one half of the population specializes in producing offspring while the other half specializes in something else, losing the ability to carry children completely, although this varies from one species to the next. There’s no inherent reason for only two sexes and many species exist with more than two sexes, like [Tetrahymena thermophila](https://en.wikipedia.org/wiki/Tetrahymena#T._thermophila:_a_model_organism_in_experimental_biology) with seven different sexes that reproduce in 21 different combinations. Basically the point of sex is to ensure you can’t mate with your own type or just clone yourself because that tends to be bad for diversity and fighting disease (a virus that finds a bunch of clones in a room will have a better day than one that finds a bunch of somewhat different individuals).
Latest Answers