But it’s more efficient to mass produce rather than have every country producing everything it needs. On top of that, some countries have inherent efficiencies in producing some items - proximity to resources for example.
You have the effect "mix vs sort" that shows that if you are very good making thing you are bad distributing them. So mass production is not as effective as local production if you account transportation externalities.