I’ve found that it’s not easy to lose weight and maintain it by cutting calories. It requires serious and disciplined changes in the total portions of food (which is one factor) over a lifetime. Even with discipline, I lost a few but gained almost all of it back with just a few days of slippage. That was disappointing.
Working out to compensate for a piece of cake or some other food is a total non-starter. You calculate and compare the calories (between food and exercise) and realize that intake control is the only place you can (as an average person) work on for decent results. This is all the more so if your genetic or bodily makeup is such that it’s easier to gain weight than lose it.