Calories in/calories out. Butter is fat and some sugar and protein. Pasta is mostly carbs. But they all become calories, and if you eat more calories than you burn, they will be stored as fat.
The poster above is correct thay sugar is the easiest for your body to turn into calories, and carbs are basically complex sugars. Fat is also fairly easy for your body to convert to calories, and it is usually more dense. Protein is the hardest, but even protein will make you fat if you eat enough of it.
If you want to lose weight, burn more calories than you consume. Everything else is nuance.
No. The butter in my fridge has almost no sugar (0.6g in 100g) and almost no protein (0.7 g in 100g).
Pasta is mostly carbs.
For comparison: The pasta I have at home have more sugar (most have roughly 3g in 100g) and way more protein (12g in 100g).
they all become calories, and if you eat more calories than you burn, they will be stored as fat.
Are you sure you're not simplifying too much?
Also, "just" eating less or more calories is not that easy if you ignore the side-effects. Carbohydrates will make you hungry very soon unless mixed (or eaten after) fibers, fat and protein. Which you should do anyways for health reasons.