Depends on the species.
The two biggest, the basking shark and the whale shark, are filter feeders and can't hurt humans unless they ram or swipe at you.
Many are too small to be a realistic threat.
Sharks will eat a dead animal, and kill if necessary. But shark attacks to humans are quite rare. If you are swimming where sharks are, the shark might mistake you for a seal, a dolphin or some other animal. In fact, it is extremely rare for a shark to attack a human knowing what their victim is. Sharks can smell blood from miles away, and are easily attracted to it.