I wondered about this for years and years, never understanding, especially, since "having cake" and "eating cake" are used interchangeably. But, I finally figured it out! In this sense, the "having" is equivalent to "keeping" or "being in possession of."
Examples:
"What's it like having a Mercedes Benz?"
"The Smiths have a very nice home."
No eating implied!
Therefore, the saying is more inline with "You can't keep (to show off or admire) your cake, and eat it, too."
One time I baked a whole entire cake for myself. There was no occasion or anything I just wanted to have a cake and eat it too. It turns out cakes are really big and it's really hard for a single person to eat a cake faster than it turns all spongy and icky.