Butter can come either hydrogenated or non-hydrogenated, though most of the time it is not hydrogenated. With hydrogenated oils comes a lot of things that are not good for your body, such as trans-fats. These are what can contribute to weight gain and butter does not have any of them, though it does contain a lot of saturated fat which is of course bad for you as well.
Margarine is a healthier alternative to butter in the sense that it does not have any saturated fat, although it is loaded with trans-fat. Those who are trying to make up their mind as to which one they want to get will have to take the time to think about which types of fat they are trying to avoid the most. When it comes to avoiding weight gain, saturated fat is the kind you will want to stay away from the most.