We aren't talking about cake though. We are talking about inexpensive highly processed foods made predominantly from ingredients that are subsidized specifically because of their caloric density. I.e. corn.
High caloric density is what you want if you need to be able to feed your country in war, so we subsidize these foods.
No one wants to eat just plain corn though, so companies process it into other foods that are then sold cheaply because they are receiving these large subsidies.
People end up consuming large quantities of these foods because they are cheap, and our brain reward centers a pre-wired to love lots of cheap easy calories.
Knowing all of this, it makes perfect sense to tax the living crap out of highly processed foods that are made from subsidized ingredients. You're just taking back the subsidy you put there in the first place, and shaping consumer behavior for the greater good (which is a common use case for taxation).