First some terms that everybody probably already knows. The usual scheme for organisms with sex is for each parent to contribute half of their genetic code. The parent has two sets of DNA and is called diploid. The parent produces specialized cells called gametes, each carrying one set of DNA, and this is called haploid. The gametes join to produce a new full set of DNA, and the newly formed organism is a zygote. This is all very much highschool biology, and is much more complicated than I have described here.
Suppose the species had two phases, one where zygotes grew to adulthood and reproduced under one scheme. And another where gametes grew to an alternative adulthood and reproduced under a different scheme. The gametes are haploid, the zygotes diploid. There would be one pair of sexes for zygotes. And a different set for gametes.
So instead of XX and XY as mammals arrange, it might be XX and XY in zygotes, and X and Y in gametes. The gametes might reproduce through some different scheme such as self-cloning. The X and Y gametes might even be sufficiently different as to not obviously be the same species.
There could be distinct sorts of X and Y. For example, X1, X2, X3, etc. When any of them is joined to a Y, the result might be an ordinary looking zygote. But the gametes witth X1 might look quite different to those with X2 or X3. So, in principle, there could be many very different looking creatures, each capable of mating with any Y type gamete.
There would be some environmental factor that would switch from one phase to the other. Perhaps if the food supply is unusually good then the gametes join up to produce some zygotes. Or perhaps there is a fixed time between the two phases, say a prime number of years. Or perhaps something in the climate is cyclic, such as drought for 10 years then wet weather for 10 years. Maybe the immature zygote requires pools of water to develop. There are many possible things that could switch the phase.
There are some organisms that, at some point in their life, go through a metamorphosis. For example, frogs have a tadpole stage, then the tadpole grows legs and lungs and becomes an air breather.
Some species of salamander have a stage where they have gills and live under water. They must metamorphose into land creatures, gain lungs and lose their gills, in order to reach adulthood.
Some creatures that do this can get "stuck" at the pre-metamorphosis stage.
Axolotls are neotonous. This means, they do not go through metamorphosis, and breed without reaching the "adult" stage. At least a few varieties can be induced, through injections of iodine, to metamorphose into the form typical of salamander adults. (It is not recommended since it often results in the death of the creature.)
Imagine a creature with the ability to breed either before or after such a metamorphosis. That is, there might be a gills-live-in-water adult form. And a second lungs-live-on-land form. And either form could breed. The pre-met form could have male and female. And the post-met form could also have male and female. But a pre-met female might become a post-met male. That is, there might be pre-met male and female that were distinct from post-met male and female. Possibly resulting from the expression of different genes. Or possibly turning on/off a different collection of genes on the same chromozome.
So there are four combos depending on sex before and after met. m-m, m-f, f-m, f-f. Each of these could be quite different. The specific pattern could be determined by environmental factors.