Answer
See explanation.
Work Step by Step
Water expands when it freezes, which is opposite to the behavior of the pipe material. The water inside a pipe, if frozen, will push against the walls with great force, possibly bursting the pipe.
A similar thing would not happen in a mercury thermometer. Both mercury and glass contract as the temperature becomes lower, and in fact, mercury contracts more than the glass does (the coefficient of volume expansion for mercury is greater than that of glass).
Furthermore, the mercury does not completely fill the hole in the glass thermometer at room temperature, so there would still be space for it to expand into.