As LV says, the body really works better on 'trends' in the diet. Meaning a consistenty weekly trend of a calorie deficit leads to weight loss (ideally fat loss) while extra calories should lead to muscle mass increase.
The body says "ok, I have extra stuff on a regular basis, and these muscles keep getting torn up...I'll use the extra stuff to make them bigger since I seem to get a steady surplus of stuff all the time"
its for this very reason that one day of cheating on a diet doesn't undo all your weight loss, or a day of bad eating doesn't strip you of the lean mass you gained.