There are a number of dangerous sea creatures. Many have the capacity to severely injure or even kill people. But they very rarely attack for no reason.
Common sense is the best way to avoid an attack.
More people are killed each year by bees or even lightning than by sharks. When a shark does attack, even if it is just 'testing', the results can range from minor cuts and gashes to severe, or fatal, results. Sharks generally attack in inshore waters, near deep channels or where rivers empty into the sea. This is because these areas are where they expect to find their 'normal' food. The best defence is to never swim alone, or in areas where dangerous sharks are known to be found.