Why doesn't integrating the area of the square give the volume of the cube? I had a calculus course this semester in which I was taught that the integration of the area gives the size (volume):
$$V = \int\limits_a^b {A(x)dx}$$
But this doesn't seem to work with the square. Since the size of the area of the square is $x^2$ then $A(x) = {x^2}$, then: 
$$V = \int\limits_{ - r}^r {{x^2}dx}  = \left[ {\frac{{{x^3}}}{3}} \right]_{ - r}^r = \frac{{{r^3}}}{3} - \frac{{ - {r^3}}}{3} = \frac{2}{3}{r^3}$$
It's clear that this is not the volume of the cube. Why is this the case? Am I misunderstanding something?
 A: It should be:
$$V = \int_0^a a^2 dz$$
where $a$ is the length of one of the sides of the square.
Or using your notation:
$$V = \int_0^x x^2 dz$$
where $z$ is the dimension over which you are integrating.
A: Actually, you have two errors there:
The minor one is that you seem to want a cube of side $2r$,
since your integral goes from $-r$ to $r$.
The major error, as others have said, is that you are finding the volume of a pyramid, not a cube. Actually, since you are integrating from $-r$ to $r$,
you are finding the volume of two pyramids, one upside-down, touching at their points. That is why you get $2r^3/3$, when the volume of one pyramid is $r^3/3$.
A: Can you tell what your proposed solution represents? I think it's far more interesting (and important) for you to be able to look at the integral, and be able tell what it means.
If you think of $x^2$ in terms of the area of a square of sides $x$, then your proposed integral calculates the volume of a solid that consists of two identical square-base pyramids (like an Egyptian pyramid) placed tip-against-tip, fashioning an hourglass-looking solid (but with flat sides). The tips of both pyramids meet at the origin and each pyramid is $r$-units high. Do you see why that is the case?  
The volume also happens to be the same as that of an irregular octahedron of edge $r$ that measures $2r$ vertex-to-vertex. It's trivial to go from square hourglass to the octahedron by grabbing one of the pyramids and flipping it over, so they meet at the base instead of the vertexes. Note that this is a "pointy" octahedron, not a regular (platonic) one because the faces of the pyramids don't come out to be regular triangles (here's how I convinced myself of that: the section of the pyramids is a triangle of base $r$ and height $r$. That's "taller" than a regular triangle; the faces of the pyramids are like taking one of these sections and stretching it outward by pulling the base, so they are necessarily even "taller" than a regular triangle).
But $x^2$ doesn't have to be the area of a square (in fact, it doesn't have to be an area at all; we just like geometric interpretations because they are fun).
Among other things, $x^2$ can be the area of a circle of radius $x\over\sqrt{\pi}$ (do you see why?). In that interpretation, your integral calculates the volume of a cone (again, in the shape of an hourglass). The volume of a cone is indeed $1\over 3$ of the volume of its enclosing cylinder, which in this case would have a base of $r^2$ (the largest of the circles) and height $2r$ (one $r$ for each half of the "hourglass"). That is, ${1\over3} \times (r^2 \times 2r) = {2\over 3} r^3$.
What's so special about the circle and square interpretation of the formula? Absolutely nothing! Even after deciding that we are looking only at geometric interpretations of the integral, the integral makes no statement about the shape of the figure whose area the integrand calculates. As long as the area equals to the square of its height from the horizontal plane, the figure can be shaped like a circle, a square, or a flattened pretzel, and the volume of the extruded hourglass-looking volume will always be the same.
Playing with these geometric interpretations is a great way to become comfortable with integrals, and should teach you over time a sense for when "something looks wrong".
A: The real problem here is not the endpoints of your integral, it's that the function you are integrating is not constant with respect to the variable of integration.  A cube has the same cross section everywhere, while in your original integral the cross section is bigger at the ends than in the middle.  See @response's solution for the right way to set this up.
A: In general if a solid has cross-sectional area $A$ which is constant along its normal length say $L$ then the volume of such solid is $$\color{blue}{V=\int_{0}^L Adx=A\int_{0}^L dx=A[L-0]=AL}$$
In fact, the area of the square is not varying with the distance $x$ in a cube. It is $a^2$ which is constant along entire length $x=a$ hence, volume $V$ of cube =\int_{0}^a a^2dx=a^2\int_{0}^a dx=a^2[a-0]=a^3$$ 
