Updated: Dec 19, 2021
The simple answer is that it is uncountable because it was once a liquid.
The complicated answer is this: it's both. This is because 'cake' has a 'whole countable form'.
Let's look in more detail.
This is cake. It is uncountable.
Can I have some cake please?
I had just a little cake.
There was a lot of cake at the birthday party.
This is a cake. It is countable.
It is countable because it is in a 'countable form' (whole).
I ordered one cake for the birthday party.
There were two wedding cakes!
The shop had at least seven different cakes.
Watch this and you'll see that 'countable forms' are important.
One cake, two cakes, three cakes.
These are countable because they are in a 'countable form'. Even though the material is 'uncountable', the form is 'countable'.
This is the same amount of cake. It is uncountable. It is not in a countable form.
Countable = three cakes Uncountable = a lot of cake
Other countable forms of cake: piece and slice
Do not worry about the difference. In my mind 'slice' is for pre-cut round cake (like in shops) whereas 'piece' is for uncut or non-round cake. That is not a rule so you don't need to learn it.
Eight slices Four pieces One slice
All these are countable because they are in a countable form.