Feel Bad On Purpose??

I’ve noticed a pattern of eating food that I know will make me feel physically terrible, yet I eat it anyway.
I understand that when we have patterns of behavior, they are serving us somehow or we wouldn’t be doing it. But this one doesn’t seem to make any sense and I’d like to uncover why I do this.