I first learned how to swim around the age of 7, It was a really, really, really long time ago so I have no exact way of knowing. I know it was after grade 1 and before grade 5.
How did I learn? I was lucky to live by the ocean, I stayed in the shallow part of the ocean beach until I got a feel for the water, then eventually moved deeper untill the water was up to my chin. Only then could I learn how to stay afloat, if you go to shallow, you cant really float because you displace the water, and hit the bottom before you ever start to float. What's the trick? There is none, learning to float is realizing that there is nothing to learn, no trick, no special ability. You just relax, and you float. If you are upright, you use your feet to move water under you, generating a slight upward lift. If you are lying flat on your back and sleeping on the water, the trick it to 100% completely and totally relax.
Learning in an ocean helps a lot, because sea water is more dense, due to the salt. Lake, river and pool water is far less dense.
The most fun I had is when I realized I could take a really heavy rock, hold it in my hands and walk under the ocean, on the ocean floor. Pure bliss.