Several factors can contribute to shark attacks, including curiosity, territoriality, and mistaken identity. Sharks may be curious about novel objects or people in their environment and may approach them to investigate. They may also be territorial and defend their territory from perceived threats, including humans. In some cases, sharks may mistake humans for their usual prey, such as seals or sea lions, and attack them accordingly.
It is important to remember that shark attacks are relatively rare, and the chances of being attacked by a shark are very low. Nevertheless, it is always important to take precautions when swimming in the ocean, such as avoiding areas where sharks are known to be present and not swimming alone.