It's kind of instinctive behavior.
Animals in wild can't find food every day and when they do find they eat as much as they can because they don't know when the next meal will be.
Dogs are also prone to develop obsessive-compulsive behavior; it might be about food, a toy, or his friend (you.)