Ricardo’s proof applies to comically simplified conditions which fail to consider a number of factors that exist in real world trade and resulting shifts of specific industries between countries including:
(1) potential impacts of current activity on future production possibilities, and
(2) strategic impacts of different production patterns and how that effects non-trade international relations, including war.
That's not to say it's not an important result that has massive implications for policy, but it is far from proof that protectionism is a bad thing in every case. It does prove that it always comes at a short-term cost, so you'd better have a specific long-term strategy that justified the short-term cost, though.