Search for the idave diet. It isn't as simple as calories in compared with calories out but what and when you eat and how your body responds to the food eg insulin response to sugar.
Eating 1000 calories of sugar each meal will not have the same affect as eating 1000 calories of fat for each meal. The sugar will a make you fatter than the fat. This is rather complicated, but in essence the rise in blood sugar causes an insulin surge which makes your body use the sugar in the blood as energy, after a while the blod sugar drops and you are starving for more sugar. If you eat fat there is little or no insulin response and the body uses glycogen and fat for energy whilst blood sugar stays more level without hunger peaks.
I may have the process wrong, but the overall concept is right. Sugar is more evil than fat.