Swimming may be dangerous if you are not familiar with the local conditions like currents and depths. Currents may be found even close to shore. Always ask for local advice before swimming in new places especially in the ocean.
Water swallowed during swimming may contain bacteria like Salmonella, Cholera and virus like hepatitis A.
Fresh water in the tropics may contain parasites (Snail fever, Schistosomes, Bilharzia), which may infect the swimmer by penetrating the skin. Avoid swimming in fresh water in the tropics before asking local advice about Schistosomiasis.