Both contribute fat to our diets. That isn't all bad. All of us need some fat in our diets.
Fats keep foods from sticking to the cooking pan, and they transfer heat from the pan to the food.
When baking, fat in doughs and batters contributes to the consistency and quality of the end product. Fats separate the starch granules in flour. The more thoroughly fat mixes with the starch, the smoother the baked product. Carbohydrates contribute 4 calories per gram, proteins 4 calories per gram, and fats 9 calories per gram. All fats, including margarine and butter, fit at the top of the food guide pyramid, in the little triangle that includes foods we should eat sparingly.