A cube is a special type of square prism where the lengths in all three dimensions are the same.
In short, all cubes are square prisms but not all square prisms are cubes.
In order to be a square prism, it must have two square bases and a square cross-section all the way through, but the third dimension doesn’t have to be the same as the other two.