Water expands when it freezes because water molecules are not shaped like most other liquids. When water starts getting colder, the molecules move closer together, but the shape of the molecules means that there is a lot of empty space between them. This makes the water take up more space and expand as it freezes.
The molecular structure of water is essentially crystalline. The fact that water molecules are less dense when they are frozen is also why ice floats on liquid water. The denser configuration of the liquid water keeps the frozen molecules of the ice from passing through.