There is a single layer of cubes on the outside that has > 0 faces showing.
Thus the interior "cube" of cubes with faces not showing is going to be of dimensions $(n-2)(n-2)(n-2)$, i.e. n, minus the right and left layer, and minus the top and bottom layer, and minus the front and back layers. So altogether there are $(n-2)^3$ cubes w/no faces showing.
Cubes with one face showing are on the outside layers but not along the intersection of two layers.
There are going to be $(n-2)(n-2)$ cubes per face having a single face showing thus a total of $6(n-2)^2$ as there are six faces.
Cubes with 2 faces showing are along the intersections of two large faces but not at the corners.
There will be $(n-2)$ cubes along each of these intersections. There are 12 intersections. 4 at the top, 4 on the bottom, and the 4 sides so there are
$12(n-2)$ cubes with 2 faces showing.
It should be clear that there are always 8 cubes with 3 faces showing. These are the corner cubes.