Translation:I bought five pieces of fruit cake.
The English translation is slightly misleading, ask for a slice of fruit cake in English and you'll get a thick dense spiced brick, made with nuts, and dried and candied fruit. I think what most Chinese mean by 水果蛋糕 would probably best be described as a "fresh fruit sponge cake".
If you have eaten cake before, you know that the cake can be cut up into slices and then each slice can be sold independently. In here, the sentence says that "I bought 5 slices of fruit cake", not 5 whole cakes, because there is the classifier 块, so "I bought five fruit cakes" is unacceptable.
If you want to say you bought 5 whole cakes, say 我买了五個水果蛋糕。
Chinese "measure words" can be tricky, and "piece" isn't the most complete definition for "块"; its also used for money " 一块钱" (so I think "unit" might be better). There are some instances where "五块蛋糕" being packaged for individual sale could be a size and shape that someone might describe them as "5 cakes", but the 1st thing I'd think of when hearing "5 cakes" would be 5 large whole cakes