The anomalous behaviour of water is that it contracts from 0oC to 4oC and beyond 4oC it expands. Thus, the density of water is maximum at 4o
When the surrounding temperature falls, the water in oceans and rivers cools down and say the temperature of whole water reaches 4o
Thus, the water reaches its maximum density at this temperature.
Below this temperature (4oC), the water layer on the surface expands due to anomalous behaviour of water because of which it's density decreases.
Thus, this colder layer remains on top and converts into ice which acts as an insulator and does not allow the temperature of water layer below it to fall below 4o
In this way, When the water bodies (such as lakes; rivers; seas;), freeze in cold countries in winter, only the upper surface freezes to form ice. Water below ice liveable temperature is maintained for the aquatic life, stays at 4ºC and hence, water animals can survive.