According to AnimalQuestions.org, not all sharks are scared of all dolphins. Those sharks that are scared of dolphins are typically scared because the dolphins have learned how to defend themselves.
Sharks often prey on dolphins. AnimalQuestions.org writes that three-quarters of wild dolphins have scars related to shark attacks. However, dolphins have exhibited the power to defend themselves through lethal means when necessary. One example of this occurred in the 1950s, when a sandbar shark made the mistake of getting too close to the birth of a bottlenose dolphin calf. In response to the shark's proximity, three of the adult male dolphins attacked in unison. Together, they butted the shark in its gills and stomach until it died.
In rare cases, this ability can be taught by humans. In the 1960s, the U.S. Navy trained bottlenose dolphins to attack large sharks and incapacitate them through attacks to the gill pouches. The trained dolphins were likelier to attack breeds of sharks that do not typically attack dolphins in the wild, but they were hesitant to attack sharks that did typically attack dolphins, such as bull sharks. While it is possible some sharks learn to be scared of dolphins due to their self-defense abilities, Sharks World points out that some sharks may be scared or annoyed by dolphin noises.