How does water flows through pipes in cold countries?
From the Wikipedia page on Frost Line  


  The frost line—also known as frost depth or freezing depth—is most commonly the depth to which the groundwater in soil is expected to freeze. The frost depth depends on the climatic conditions of an area, the heat transfer properties of the soil and adjacent materials, and on nearby heat sources. For example, snow cover and asphalt insulate the ground and homes can heat the ground (see also heat island). The line varies by latitude, it is deeper closer to the poles.      


So they just dig the pipes in deep.   


  Canada: Can use table of estimates based on freezing index degree days.
  Ontario: Map of frost penetration depths for Southern 
  
  
  Ottawa: 1.8 metres (5.9 ft) [7][8]
  Windsor: 1.0 metre (3.3 ft) [7][8]
  


Here's a  soil temperature vs depth graph.

Source