One could argue that they don't - that we should be defining sex differently (Biologists define the "female" of a species as the one which produces the larger sex cells, the eggs).
But seahorses have the unusual quality of the males being "pregnant." In reality, they carry their eggs around in a pouch.
Male egg nurturing is not uncommon in oviparous species, but only seahorses, pipefish and seadragons (and not all of them) incubate eggs in a specially designed pouch. Some species have started to provide food for the developing offspring through "attachment sites." And some species can actually absorb the eggs/embryos.
So, it's pretty dang close to pregnancy. But even a full sequence of the genome of the Tiger Tail Seahorse has not revealed how the switch from the females incubating to the males doing so took place.
I suspect that there was probably an intermediate stage. In many species of fish the male does the tending or builds the nest. It also could be that at some point they were paternal mouthbrooders - the male cared for the egg in the mouth - and then evolved a special pouch. Or...maybe it started by sticking the eggs to daddy.
What we can't do is trace the genes that cause it. So, seahorses keep their secrets, for now.
(Paternal mouthbrooders include the arowana, mouthbrooding betta, black-chin tilapia and sea catfish).