You may have counted only the number of cubes that fill one layer of the rectangular prism. To find the volume, you need to count the number of cubes that fill the entire rectangular prism.