In the single displacement chemical reaction, one element is combining with a compound. This element switches it's place with an element from the compound.
The general formula of this kind of chemical reaction is:
x + yz --> xz + y
As we can notice, the x element is replacing y element from the original compound yz. The result is the new compound xz and the new element y.
When magnesium is combined with water, the magnesium element is replacing hydrogen from water. The result is magnesium hydroxide and H2 gas.
Mg + 2H2O --> Mg(OH)2 + H2
The double displacement chemical reaction occurs when anions and cations from different molecules are changing places, creating 2 new compounds.
xy + zw --> xw + yz
Conclusion: single displacement chemical reaction: x + yz --> xz + y and double displacement chemical reaction: xy + zw --> xw + yz.