When we move a single charge q through a potential difference ΔV, its potential energy changes by q ΔV.
Charging a capacitor involves moving a large number of charges from one capacitor plate to another. If ΔV is the final potential difference on the capacitor, and Q is the magnitude of the charge on each plate, the energy stored in the capacitor is:
U = 1/2 QΔV.
The factor of 1/2 is because, on average, the charges were moved through a potential difference of 1/2 ΔV.
Using Q = C ΔV, the energy stored in a capacitor can be written as:
U = 1/2 Q ΔV = 1/2 C(ΔV)2 = 1/2 Q2/C