"cannot help but"/"can't help but"/"could not help but"/"couldn't help but" are examples of an idiom that is followed by an infinitive. In this case the infinitive is "eat": "I couldn't help but eat the cake". You can't use the past tense or other verb forms after "help but" in this idiom.
The Grammarphobia blog has written about this. Some usage guides say not to use "help but" in formal writing, but most people think it's fine. Examples they give include:
- I couldn’t help but cry over that.
- They cannot help but feel the responsibilities.
- Sympathy is an impulse which we cannot help but experience for one another.
There are many other ways of using "help": "I couldn't help myself" on its own is another idiom, meaning "I was unable to control myself". You can also use "I couldn't help eating", which means the same as "I couldn't help but eat" - which is confusing. So 2, 3, 4 are correct, but not 1.