If we stack the prism of each one of you, we would get the following solid:
As you can see, the width (2 cm) and length (4 cm) of the prism remain the same, only the height changed, now it is 3 cm since we are staking 3 prisms of 1 cm height each.
For rectangular prisms, we can calculate the volume by means of the following formula:

Where l is the length, w is the width and h is the height of the prism, by replacin