As soon as your child is capable of independent motion, they are capable of getting into water and drowning. Therefore, swim lessons should begin as soon after 4 months of age as possible.
Initially, they will not learn to swim per se. They will be learning: "ROLL OVER, FLOAT, YELL FOR HELP." Young children, because of the weight of their head and body proportions, can't readily "learn to swim."
What you want, is to keep them SAFE. We do that by teaching them to surface when underwater, roll onto their backs, maintain themselves and breathe and YELL FOR HELP! History shows that this response SAVES LIVES because it "buys time" for the caregiver to realize that the child can float and yell.
Tragedies occur when the child can't perform that skill. Once they have mastered ROLL OVER, FLOAT, YELL FOR HELP! Then we begin teaching "real swimming."