Yes snakes can and do swim under water.
Most snakes that are poisonous or venomous swim underwater or in the water with their lungs fully inflated which causes the swimming snakes bodies to float on the surface of the water.
If the snake is swimming and has it's head only above water then it's likely a non poisonous snake or non venomous snake.
That's usually one way you can tell the difference between a poisonous snake and a non poisonous snake is through the way they are swimming.
But usually all snakes do have the ability to swim under water and in the water so be sure to watch yourself and your family if you go swimming in creeks, ponds, lakes etc especially if the water is dirty looking and you can't clearly see what is under the water.
If you see a snake swimming in or under the water you should get out of the water if you're in the water.