While looking into the Oleomargarine Act I have had a particularly hard time finding an explanation for what caused it to be enacted in the first place. This is a fascinating bit of history to me and I'd appreciate any insights as to why this happened.
So, margarine isn't a product that was just created on its own - it was invented as a replacement for butter. In 1869, France was facing a shortage of butter, and Napoleon III's government offered a challenge with prize money to anyone who could produce a new type of fat to alleviate the problem. The chemist Hippolyte Mège-Mouriès took them up on it, creating something with beef tallow mixed with skim milk, and he named it "oleomargarine" - oleine and margarine were two kinds of natural fats that turned up in it. The butter shortage cleared up, but over the course of the 1870s margarine began to be produced across western Europe and in the United States. It wasn't as good as butter, but it was certainly a lot cheaper, since it was mostly made out of byproducts, and it could be colored yellow to look as appetizing as butter. (And sometimes it was labeled as butter, in a bald-faced lie.)
Almost immediately, margarine became a kind of matter of state. People generally don't realize how strong the dairy lobby is today, and it was at its strongest in the second half of the nineteenth century. In rural areas, dairy farms were/are big business, and demand(ed) large subsidies and protections in order to keep going. George Taylor, MP for Leeds South, argued successfully to Parliament that animal husbandry was the most important domestic industry and dairy the most important side of animal husbandry, and that while building margarine factories could be seen as creating industrial jobs etc., they were impoverishing the farmers. There was also an emotional component to his argument, due to the centrality of the idea of agriculture to the national myth. (Think of the way people might refer to "the heartland".) Despite arguments that margarine spurred butter-makers to make a better product, dairymen had been tossing around the idea of a total ban by 1884. After three rounds of debates in Parliament, there was finally support for a full ban on the grounds that margarine was a counterfeit of butter rather than a product in its own right, and that it was almost always mislabeled as butter for sale (untrue). Some American states and European countries also prohibited it, or prohibited the use of dyes to color it to look like butter rather than lard. While these methods did help out dairy manufacturers, they were cruel to the poor - margarine isn't great, but it was significantly better than the greasy, rancid "renovated" butter that was all they could afford. When you get down to it, governments weren't that concerned with adulteration and protecting the consumer: they cared about helping out the dairy farmers.
The margarine bans weren't lifted until the early twentieth century, when the rationing pressures of World War I meant that butter substitutes were really needed again. The development of hydrogenation also allowed manufacturers to turn vegetable oil into a more spreadable solid, and with the use of better flavorings and dyes, they were able to turn out a product that the public really liked. I don't think we can underestimate the effect of the domestic science movement on this, either - people were more convinced than before that a factory-made product was better and healthier than a "natural" or "artisanal" one. Unlike the dire predictions made by the dairymen's associations and lobbyists decades earlier, margarine did not kill off butter, or even really cause it to suffer any downturns. Completely unnecessary protectionism!
The claimed reason for banning margarine was to protect consumers from a harmful product. The USA added a further reason: protecting consumers from margarine being fraudulently sold as butter. I don't know if this was given as a reason in 1886 in Canada, but it certainly featured in later debates on margarine legislation - it was one reason why, when margarine was allowed to be made/imported/sold in Canada from 1919-1922, it was only uncoloured margarine that was permitted.
The main reason was protection of the dairy industry. The main pro-prohibition legislators were from dairying areas (notably, Ontario). The Canadian and US bans on margarine were about money - dairy industry money.
Uncoloured margarine was a compromise. When the health/harm issue could no longer be believably used to support margarine prohibition, uncoloured margarine could be pushed by the pro-dairy legislators as protecting consumers from fraud, while protecting the dairy industry by making margarine less attractive to consumers.
For an overview: Dupré, Ruth. “‘If It's Yellow, It Must Be Butter’: Margarine Regulation in North America Since 1886.” The Journal of Economic History, vol. 59, no. 2, 1999, pp. 353–371. www.jstor.org/stable/2566555
For the health/harm debate: Caroline Lieffers, "“A Wholesome Article of Food”: Rhetoric of Health and Nation in Canada’s Oleomargarine Debates, 1917-1924", Canadian Bulletin of Medical History, Volume 32 Issue 2, Fall 2015, pp. 337-362. https://www.utpjournals.press/doi/abs/10.3138/cbmh.32.2.337