Do cakes have definite chemical compositions? Yes.
Think of it this way.
The ingredients needed to make a fruit cake are: eggs, butter, flour, sugar and fruit. If you miss out the flour the cake will be soggy. If the amount of sugar is wrong, it won't taste right.
The chemicals in a mineral are just like the ingredients in a cake. There has to be exactly the right amount of each chemical for the mineral to form properly. You cannot leave out any of their 'ingredients'. Cakes are like minerals in this way.