Margarine is made from vegetable oils high in polyunsaturated fats like sunflower, corn, soy or canola oils. Due to the complexity of their molecules, these oils remain liquid even when cold. How then do we turn these oils into solid margarine?
The manufacturing process is called hydrogenation. In essence, hydrogen is added, under high pressure and high temperature, in the presence metallic catalysts including cobalt, nickel and aluminium. The resulting solid margarine is then further processed and colored to make it look like butter. More details of the manufacturing process can be found here.
At one stage, margarine was colored pink in the US to distinguish it from butter. In fact, <Pink Margarine> is the title of an interesting book on the conspiracy theory regarding margarine.
In the hydrogenation process during the manufacture of margarine, the structure of the molecule is altered. The idea is to make the polyunsaturated fat more stable, but the end result is not the same natural saturated fat as is found in butter. In effect, trans-fats are produced. This is a change in the double bond configuration which is originally cis. The change in the molecule results in an alteration of the three-dimensional configuration of the oil, with dire consequences.