Butter is rich in cholesterol-raising saturated fat. But margarine is typically rich in trans fats, which raise cholesterol, too.
From a health standpoint, it makes sense to avoid them both. But there are exceptions to this rule. Some margarines are made with special compounds, called sterols and stanols, which lower cholesterol.