Water contracts when heated and expands when freezing. It expands on freezing because it forms a hexagonal shape, which takes up more room. This property of water is why soda cans explode in the freezer. The water in the soda expands too much, pushing the can to break.
Most other types of mass follow the other rule, including liquids and gases. Unlike in solids, particles move freely in liquid. When heated, the particles move about more rapidly. The movement, rather than the small vibrations that happen in solids, causes the substance to take up more space.Learn more about States of Matter