The snow on the roof melts by hot air inside the attic. This melted snow then runs down, and it freezes again when it reaches the lower part (roof overhang/eaves) of the roof because this part is cold underneath. The formation of ice on the eaves is known as ice dams. This melted snow also turns into icicles near the roof edges.
With time, a big dam of ice forms near the edge of the roof. The melted snow will eventually start to back up. The shingles are designed and laid in a way that they shed (they are not watertight like flat roof membranes) water from the roof, but when the water begins to flow backward/upward, it eventually seep under the shingles and from there, it enters the house and causes damages.