Why, from the natural selection point of view, do only two sexes exist for animals?
To get a non-circular answer to why humans and other mammals have only two sexes, it's helpful to take a look at our evolutionary history. While mammals possess several adaptations to a terrestrial life cycle, including internal fertilization and gestation, which require substantial anatomic specialization between males and females, these are all secondary features that evolved long after our aquatic ancestors had acquired two distinct sexes.
Indeed, if we look at animals like fish, which reproduce via external fertilization, it's not at all obvious why they might not have more than two sexes. After all, for many aquatic animals, mating involves little more than the female and the male releasing their respective gametes into the water, where they meet and fuse to a form new zygote, which can then divide and grow into a new adult. Seen that way, there seems to be no reason why there could not be more than two "mating types", as in many fungi, such that gametes of any two distinct types could fuse into zygote.
The answer lies in the fact that the male and female gametes aren't actually that similar: the female gametes, or eggs, are typically large cells that contain all the nutrients necessary for the new zygote to develop into a viable individual, whereas the male gametes, or sperm, are tiny and produced in huge numbers. This asymmetry is known as anisogamy, and modeling its origin has been an important topic in the theoretical study of evolution.
Without going into details on the evolution of anisogamy, once it exists, it clearly forces the mating types to also split into two groups: there's no advantage in two microgametes (sperm) fusing, since the resulting zygote would lack the nutrients it needs to be viable, whereas the fusion of two macrogametes (eggs) would simply be inefficient — eggs, being large, are comparatively rare and expensive, and wasting two of them to produce only one offspring would be suboptimal even if the resulting zygote was viable. Nor is there really room in such a scheme for gametes of intermediate size: they'd be too small to fuse into a viable zygote with sperm, but too large to be produced in sufficient amounts to be effective in fertilizing eggs.
Of course, there's nothing that would stop a single adult from producing both micro- and macrogametes, but such an adult would not really be a third sex — it would just be male and female at the same time, a mating strategy known as (simultaneous) hermaphroditism, which indeed occurs relatively often in nature.
So, if pretty much all animals are anisogamous, why do fungi remain isogamous (and often have multiple mating types), then? Well, one explanation is that the main drivers for the evolution of anisogamy — sperm competition and transportation risk — don't really apply to fungi, which mate when two sessile haploid mycelia grow and come into contact with each other. Since the gametes are not motile, there's no advantage for either/any sex to produce more of them (at the cost of smaller size) in order to increase the chance of successful mating. Thus, isogamous mating works fine for the lifestyle of fungi, and having multiple mating types is then a useful adaptation to make successful mating between neighboring mycelia more likely.
@emanuele you seem to be asking why there are only 2 sexes for animals, in contrast to fungi which can have many sexes or maybe bacteria which have mobile sex - the ability to donate genetic information can be acquired or lost.
Some animals - worms and fish for instance are hemaphrodites - they can accept sperm or donate them to produce offspring. Fungi are even simpler - the mating is by haploid fusion on the cellular level, since they have single celled life cycles. The mating type allows mating with any cell that is not of the same mating type. Its just a matter of how much genome space you want to dedicate to mating and there can be 2 mating types of 10,000 mating types - the only rule is that you can't mate with your own mating type. Its a simple mechanism to restrict mating with yourself - probably to encourage genetic diversity.
Physiologically, for single celled animals and simple egg layers like fish and worms, you can see why sexual roles might not need to be specialized; its a matter of which gamete you will deposit. If the egg is no more than an especially fat cell, becoming male is not necessarily a big change. But when eggs are more complicated structures or live birth becomes an adaptation, the expense of being the gamete donor (male) or recipient (female) becomes a significant commitment and changing roles is not so easy to do in an evolutionary system.
Ultimately, Unlike worms or snakes, committed females are specialized such that turning into a male, with the requisite development of a womb, changes in bone structure, etc is such an elaborate phenomenon that we don't observe it.
Richard Dawkins describes an elegant solution to the puzzle in his memorable Selfish Gene: in the beginning, all gametes were similar, and many sexes could coexist (like in fungus). But when some lineages began to specialize in different strategies (ESSs, Evolutionarily Stable Strategies), with some increasing and other decreasing the size of the gametes, then there was room for two sexes. Probably a third sex would only compete with one of the others, without space for niche drift, and thus one of them would usually become extinct, driving it back to two sexes again.
The purpose of sexual reproduction is to combine the genetic material from the contributing parents to produce a new individual. That combination has the potential to replace genes which may be defective and generally increase diversity in the offspring, improving resistance to certain pathogens. Bottom line: sexual reproduction confers an evolutionary advantage.
Where it occurs, why only two sexes? Simply because two is sufficient to get the job done.
Consider the perspective of one "parent", and the goal to combine genetic material from some other source of the same species in order to produce an offspring having some blend of genetic material. If that "other source" was one randomly selected individual, how does an additional randomly selected source qualitatively change the result? By the principals of statistics, it doesn't. One other source containing some random variation is no more or less random than a combination of two or more such sources. Therefore, to meet the requirements of a random genetic shuffle, two sexes suffice.
If a third sex was required, then three individuals would have to play their respective roles for successful procreation, where only two are required for the two-sex system we understand. If you compare asexual reproduction with two-sex reproduction, you might wonder why asexual reproduction exists at all given the genetic benefits of sex. The answer is in simplicity. No need to find a partner. To go from two sexes to three, there would have to be a benefit to overwhelm or at least balance the added complexity of bringing three partners together instead of just two. As previously discussed, there isn't any. Even if a three-sex system just happened to occur, it would be out-competed by its simpler two-sex rivals.