That's because of the macronutrients in sugar, not the calories themselves. With sugar, you get a massive glucose dump that your body can't process into ATP for usage all at once, so that extra energy is stored as fat. Whole wheat pasta breaks down less efficiently, so it can be burned as fuel as it breaks down. Sugar is too efficient for its own good. It's also why a glucose-starved athlete like a pro MMA fighter during a weigh-in might benefit from eating a sugar packet if they're a half pound under the weight limit. They can start getting glucose into their bodies quickly so that they can recover from the weight cut before the fight. Anyways, the glucose issue isn't a reflection of the calories themselves because, after all, it's just a measurement of potential energy.