If s is the length of a side of the slice and h is the height of the pyramid, then by similar triangles:
$\displaystyle \frac{\frac{1}{2}s}{\frac{1}{2}a}=\frac{h-y}{h}$
or $\displaystyle s=\frac{a}{h}(h-y)$
The area, A(y), of the cross section at y is:
$\displaystyle A(y)=s^{2}=\frac{a^{2}}{h^{2}}(h-y)^{2}$
Therefore, the volume is:
$\displaystyle \int_{0}^{h}A(y)dy=\frac{a^{2}}{h^{2}}\int_{0}^{h} (h-y)^{2}dy$
Using a=2, perform the integration and you should get $\displaystyle \frac{1}{3}(2)^{2}h$