Apparently it has to do with Canada converting to the metric system. Milk companies weren't legally allowed to sell 1 gallon (3.79L) jugs as "close enough", and they couldn't change the glass containers. But they had plastic 1-quart bags which they could upsize to 1.3L, and three of those made 4L.
Eventually the technology became available to quit with the shenanigans and everybody else stopped, but Ontario provincial law forced the madness of bagged milk to continue on.
As of 2018 apparently the regulation has been amended but things haven't changed lol.