A recent scientific study shows that seahorses evolved from pipefish to support their feeding style. Pipefish and seahorses are related and similar. Both feed on small animals, plankton and brine shrimp by slurping them up (kind of like slurping your noodles). Pipefish swim around and pursue their prey. Seahorses, however, wrap their tail around a stationary object, like sea grass or coral, and wait for their prey to swim by at which point they reach out their neck and slurp up their prey.
Since the seahorses are not strong swimmers, they adapted to strengthen their hunting style to get food that is further away. The seahorses evolved the S-shape because it allows them to tense their muscles and snap forward to slurp up their prey.
There is a fabulous two and a half minute video by Nature Video called “How the seahorse got its shape” showing the seahorses and explaining the findings of the recent study by Sam Van Wassenberg, Gert Roos and Lara Ferry called “An Adaptive Explanation for the horse-like shape of seahorses” published in Nature Communications. Click on the highlighted words to see the video and the study.