Both grown and baby elephants can swim in shallow or deep waters. The high percentage of body fat an elephant has helps it to float in deep waters rather than sink, and an elephant uses all four legs to propel itself through the water.
Historical writings describe elephants swimming across deep waters with nothing but their trunks above the water. Elephants use their trunks as a snorkel, and the composition of an elephant's lungs allow it to remain submerged without any additional pressure exerted on the lungs while it swims.
Elephants depend upon water to cool their bodies down. While elephants may swim for fun, it's the process of evaporative cooling that drives elephants toward water.