I think it means that once you've eaten the cake you no longer "have it" - it's gone.So you can't eat your cake but still have it afterwards.
What I've never understood is why not just eat half? Than you can have it and eat it too (half of it anyway). I've always hated this particular phrase.
In Italy we say : you can't have the barrel full (of wine) and a drunken wife