First you put a square with side of $x$ on each face ($6x^2$
cubes), then a column of $x$ cubes on each edge ($12x$ cubes), and
finally one cube on each corner ($8$ cubes).
This would give us our $6x^2 + 12x + 8$ expression, which is what
you get when you simplify the other expressions.