Nutrition-wise they matter. Calorie-wise, they don't matter as much. If you're shooting to eat a well-balanced diet, healthy carbs should be a significant part of your diet, things such as fruits and vegetables that provide nutrients as opposed to cookies and candy that don't.
If you're just looking at the thermodynamics of calories burned vs calories consumed and don't care about nutrition, where you get the calories from doesn't matter. Eating all your calories from cookies will keep you alive, but doesn't do much in the health department.
Most experts on diet say to consume 60% of your calories from healthy carbs, 25-30% from protein, and 10-15% from good fat.