The central idea is comparative advantage: a country gains by exporting what it gives up least to make, even if it is better at making everything. Suppose a worker in country A can make 10 computers or 20 shirts in a day, and a worker in country B can make 1 computer or 10 shirts. A is better at both. But a computer costs A 2 shirts of lost output, and it costs B 10. If they trade at 5 shirts per computer, A receives 5 shirts for a computer that cost it 2, and B pays 5 shirts for a computer that would have cost it 10. Both end up with more than they could make alone. These are the gains from trade.
A tariff is a tax on imports, paid at the border by the firm that brings the goods in. It raises the price of the foreign product, which lets domestic producers raise theirs as well. In February 2018 the United States put a tariff of 20% on the first 1.2 million imported washing machines each year and 50% on the rest. Flaaen, Hortaçsu and Tintelnot (American Economic Review, 2020) found that washer prices rose about 12%, and so did prices of dryers, which carried no tariff but are often bought with a washer. They put the cost to consumers at about $1.5 billion a year. Set against the roughly 1,800 jobs attributed to the policy, they estimate a cost of more than $815,000 per job, even after subtracting the tariff revenue.
The theory is often asked to say more than it does. Comparative advantage is not absolute advantage: a country does not have to be the best at anything to gain. The gains go to the country as a whole, not to everyone in it. Workers and owners in industries that compete with imports lose, which is why trade policy is fought over. And a trade deficit is not a loss in the way a firm's loss is. It mirrors the gap between what a country invests and what it saves, which is explained in Balance of Payments. How currencies are priced is covered in Exchange Rates.