Tolkien scholar Michael Martinez answers this question on his website:
So, let me preface my answer by saying that I believe J.R.R. Tolkien had a very specific image in mind about his dragons, in terms of how they would fly and how they would move across the land. And I think he must have felt that the act of flying would impair some of a dragon’s physical actions, such as breaking into buildings and grabbing people (either to eat or to kill with his powerful jaws). But we can also look at the behavior of dragons in Tolkien’s stories. For example, Glaurung (a non-flying dragon) loved to taunt his victims, and to cast spells upon them. Thus he wove his evil magic around Turin and his sister Niënor. Smaug, too, sat upon his mound of gold and searched for Bilbo even while engaging in a contest of wits with the (invisible) Hobbit. Finally, Dáin I and his son Frór were both slain at the door to the dwarf-king’s hall by a cold-drake.
So I think that Tolkien felt there was a very strong, perhaps necessary ground-based behavior for dragons. We don’t know if the cold-drake could fly or not. We’re not even sure what Tolkien meant by “cold-drake”, since his other dragons apparently all breathed fire. Whether Smaug could have crawled over the buildings of the town without sinking into the water is not clear to me. Tolkien’s full-color illustration of Lake-town seems to suggest that the piles supporting the buildings were of a similar strength to the piles supporting the main bridge.
Should the men of Lake-town have known how much weight the bridge could bear? In other words, in order to create a dragon-trap, how would they know what a dragon’s weight should be? It’s not like they could weigh and measure Smaug before he attacked. Furthermore, their carts and horses might — collectively — equal a dragon’s weight depending on the loads they were bearing, so they would run a risk of drowning themselves if the bridge collapsed under “a dragon’s weight”. I think, therefore, that Tolkien had the right idea in that throwing down the bridge would discourage the dragon from creeping up to the houses and clawing around inside for people; also, he would be unable to easily climb over the houses and scoop people from their boats.
Landing on the buildings might, in Tolkien’s view, have exposed the dragon to all sorts of attacks by the men from many directions. Hence, in order to keep his enemies/prey in front of him he would need to approach the town by the bridge. Also, if Smaug could stand on the bridge with ease he would be able to attack any boats that tried to come near by, flaming them.
Furthermore, I think Tolkien had an idea of what powered the dragon’s fire. So far as I know he never attempted to explain this in any of his published writings. But whatever it was, water would have quenched that internal furnace — perhaps even by mere contact with Smaug’s skin. It’s as if the dragon’s body was its own furnace, and he had to maintain his distance from water in order to generate the heat to breathe fire. This is pure speculation on my part.
J.R.R. Tolkien’s ideas about weaponry and tactics have sometimes been challenged by readers with knowledge and experience in such matters, but when it comes to dragons no one is really expert enough to know if Tolkien’s dragons were realistic in any way. Tolkien’s imagination was the final authority for how his stories worked and we can only judge his logic by what he left behind in print or his private notes. Unfortunately, there is nothing that explains why a dragon would be confounded, perhaps even disarmed or weakened, by water.