Why can newborns swim?
It's called the Diving reflex, also known as the bradycardic response. It goes away around six months.

From https://www.breatheology.com/articles/mammalian-dive-response/


  Another action of the diving response can be observed in infants when they are under water. The windpipe by the vocal chords sponta­neously closes to prevent water from entering the lungs. This reflex is initiated as soon as there is contact with water. However, it disappears when the child reaches the age of roughly six months.