The area of a pyramid with a square base with side length $L$ and height $h$ is calculated as follows:
In $\mathbb{R}^3$ place the pyramid upright with one side flush with the z-axis so that the corners of the base are at $\left(0,0,\frac{1}{L}\right)$, $\left(0,0,-\frac{1}{L}\right)$, $\left(L,0,\frac{1}{L}\right)$ and $\left(L,0,-\frac{1}{L}\right)$.
We will slice parallel to the yz-plane from $x=0$ up to $x=\frac{L}{2}$. (We can then double it to get the whole pyramid.) The slices are rectangles that all have a base equal to L and height given by $f(x)=\frac{2hx}{L}$. The cross-sectional area is then, $A(x) = L\frac{2hx}{L}=2hx$.
So, we have $2 \int_{0}^{\frac L2} (2hx) dx \neq \frac13 L^2 h$.
What has gone wrong?
ANS: The slices are NOT rectangles. DUH. Thanks, Rahul Narain.