For some base area B and height h, the volume of a pyramid is
... V = (1/3)Bh
For the same base area and height, the volume of a rectangular prism is
... V = Bh
You will note that the factor of 1/3 is missing, meaning that the volume of the prism is 3 times the volume of the same-dimensions pyramid.
The prism has a volume of 3×(8 cm³) = 24 cm³.