Count the number of shapes in a polyhedron.
Each edge of the polyhedron is shared between exactly one triangle and exactly one square, as can be inferred from the question statement. Thus, given six squares, there are 24 edges ($6×4$), and thus eight triangles ($24÷3$).
The polyhedron is called a cuboctahedron.
Each square is bordered by four triangles and $6\times4=24$. However every triangle is bordered by three different squares, so it was counted three times in the multiplication above. This means there are $24/3=8$ triangles.
This isn't rigorous, but if you don't have to write a proof, just get the right number, it's clear from the illustration. You can see "one hemisphere" of the polyhedron except for a triangle parallel with the line of sight, so the total number of sides of each type are just double what apppear in that hemisphere (i.e. what you see plus the hidden triangle).