Most compounds (like CO2) will contract upon freezing. Water is unique though, and it tends to form a crystalline structure due to hydrogen bonding between water molecules. This leads to lots of empty space between separate water molecules, causing its expansion.