The craving cycle you experienced comes from dumping loads of empty carbs into your system.  It's like poison when your blood sugar gets too high.  The high blood sugar causes an overreaction.  Your body creates a massive insulin spike to clear out the excess sugar in your blood, which in turn causes low blood sugar once the excess insulin does its work, which then leads to you craving more sugar to make up for your now below normal level of blood sugar.  The whole process just keeps repeating itself until you stop dumping sugary food into your body long enough for it to normalize again.