The snow melts from the lowest layer first because heat is escaping from your home through your attic. Poor attic insulation is often the reason why the layer of snow that is touching your roof warms enough to melt. Replacing or improving your attic insulation will go a long way to preventing ice dams from forming.
Another reason ice dams form is that the water runoff path is blocked. In other words, your gutters are clogged. If water sits in your gutters, it will freeze when the temperature drops and then more water will freeze on top of that. Before you know it, you have an ice dam forming in your gutters.
If an ice dam becomes too big and heavy, it will break and fall off your roof. When that happens, it can cause all kinds of damage. If you have plants or landscaping in the area, the weight of the ice can crush it. Even worse, a falling ice dam can take part of your gutter system with it, damaging not just your gutters but your roof as well.