I believe you mean volume, not area, since the height is given as well.
If the first cake and the second cake are the same size, they'd have the same area and the same volume.
Ratio between 1st pieces and 2nd pieces:
24:40 = 6:10
= 3:5
So for every 3 pieces from the first cake, you get 5 pieces from the second cake.
Therefore, your volume of each piece of the second cake should be 45 cm^3.
Since the height is given as 3 cm, the area of each piece of the second cake should be 15 cm^2. (45/3 = 15)
Working with whole numbers (i'm assuming), the possible dimensions of the second cake pieces would be: 5 cm x 3 cm x 3 cm (and since 3 and 5 are the only integer factors of 15).
Your answer: width x length = 5 cm x 3 cm (or vice versa)