Geometry buffs: Pls explain this "How many triangles" puzzle

The first one has 24 squares as mentioned by @Chronos. Here is how I figured that out (I didn’t count them). Represent a line segment as 2+e, two vertices and on edge. Then a square is gotten by multiplying two of them, giving (2+e)^2=4+4e+4e^2, understood as consisting of 4 points, 4 edges and one square. Similarly, a cube is represented by
(2+e)^3=8+12e+6e^2+e^3
a tesseract by
(2+e)^4=16+32e+24e^2+8e^3+e^4
and a 5-cube by
(2+e)^5=32 + 80e +80e^2+40e^3+10e^4+e^5
which gives the 80 squares as described by @Chronos. But it also tells you that it counts 40 cubes and 10 tesseracts.

Incidentally, in all cases, the alternating sum of the coefficients is exactly 1. This is essentially equivalent to Euler’s formula v-e+f=2 in two dimensions.

You can write all those coefficients in a layout similar to Pascal’s Triangle. Then write an actual Pascal’s Triangle next to that, and compare them. There is a pattern there.

What does “alternating sum” mean?

Adding up - but reversing sign for each element. So for the tesseract case (as given above 16+32e+24e2+8e3+e4), the coefficients are 16, 32, 24, 8 and 1, and the alternating sum is 16-32+24-8+1 = 1