We don't know as of yet.
This particular event hasn't taken place in the books, nor has anything similar happen. The TV show didn't offer much insight either, so we can only speculate.
Maybe the white walkers can't swim, maybe they didn't want to.
There is a good discussion on Reddit.
If they could swim what's the point of the wall?
and
It could've also been a trick. Now Jon suspects they can't swim so he's only going to prepare for land attacks.
The only thing that comes close to this from the books is in aGoT, Tyrion III:
Mormont was deaf to the edge in his voice. "The fisherfolk near Eastwatch have glimpsed white walkers on the shore."
Also, on aDwD, Jon XII; this is a message sent from Cotter Pyke to Jon:
Jon read:
At Hardhome, with six ships. Wild seas. Blackbird lost with all hands, two Lyseni ships driven aground on Skane, Talon taking water. Very bad here. Wildlings eating their own dead. Dead things in the woods. Braavosi captains will only take women, children on their ships. Witch women call us slavers. Attempt to take Storm Crow defeated, six crew dead, many wildlings. Eight ravens left. Dead things in the water. Send help by land, seas wracked by storms. From Talon, by hand of Maester Harmune.
And another discussion on the forum of Ice and Fire.