Consider the figure.
From the cardboard sheet of length q and width p, we remove from the corners squares of side length x, then fold the cardboard to form a box.
the height of the box is x, the length is q-2x, since 2 x'es are subtracted from the length of the cardboard, similarly the width of the box is p-2x.
The volume of the box is height*length*width:
so the equation is
V=x(q-2x)(p-2x)