Many animals like ducks have evolved features to be able to swim. Even not so aquatic animals like a tiger evolved so that its feet can act as paddles. In humans I don't see any direct feature that has specifically evolved for the purpose of swimming. So is it just luck that we are able to swim and some of our cousins like gorillas are not able to swim? Or did we evolve in some way to be able to swim
The Jane Goodall website says: "You’ll rarely see a chimp paddling about in the water as they don’t like to swim. Their low body fat ratio causes them to sink and their top heavy body composition makes it difficult for them to keep their heads above water. However, some chimpanzees do enjoy a good splash around in shallow water."
Some monkeys have been taught to swim, see this video: https://www.youtube.com/watch?v=q2vekGuV8xA
So, the answer is, it's just luck that humans are quite good swimmers compared to other monkeys, because strong bipedal running and legs also gives humans good stability in water. After us the best swimmer is the proboscis monkey. Many other monkeys do play in water and swim: https://www.youtube.com/watch?v=sn-M1kCvzLg
There are many studies that theorize that modern humans have evolved beside seas and rivers.
Here's a massive infographin on the subject: https://visual.ly/community/Infographics/science/possible-aquatic-adaptations-human
Humans crossed the open ocean at least 50,000 years ago, i.e. to colonize Australia, the oldest evidence of fishing is currently from East Timor, 42,000 year old fishing hooks: https://www.livescience.com/17186-oldest-fish-hooks-early-humans.html#:~:text=Their%20discovery%20uncovered%20fishing%20hooks,%2C%22%20O'Connor%20said.