Tariffs are a surcharge on imports added and demanded by the government, paid by the people or entities importing.
As an example, if an American buys a Chinese coffee maker priced at $100 and there is a 50% tariff, there is a $50 tariff that is paid by the importing American to the American government.
The total cost to the importing American is $150. Now, if this price is equal to or higher than an American coffee maker then the importing American is incentivized to purchase the American coffee maker instead.
As another example, if Tesla sells Model 3s for $50,000 and BYD comes in with a similar spec car priced at $25,000, then putting a 100% tariff on it will drive BYD's effective price up to $50,000 allowing Tesla to compete without undercutting or outright selling at a loss.
Essentially, tariffs are a way to ensure that the pricing floor of the domestic market is not driven down unreasonably by international markets at the cost of the importers.
EDIT: Fixed some math. :V