Tariff
A tariff is called an optimal tariff if it's set to maximize the welfare of the country imposing the tariff. It is a tariff derived by the intersection between the "trade indifference curve" of that country and the offer curve of another country. In this case, the welfare of the other country grows worse simultaneously, thus the policy is a kind of "beggar thy neighbor policy". If the offer curve of the other country is a line through the origin point, the original country is in the "condition of a small country", so any tariff worsens the welfare of the original country.
Trade agreement
A trade agreement (also known as trade pact) is a wide-ranging taxes, tariff and trade treaty that often includes investment guarantees. When two or more countries agree on terms that helps them trade with each other. The most common trade agreements are of the preferential and free trade types are concluded in order to reduce (or eliminate) tariffs, quotas and other trade restrictions on items traded between the signatories. 
The logic of formal trade agreements is that they outline what is agreed upon and the punishments for deviation from the rules set in the agreement. Trade agreements therefore make misunderstandings less likely, and create confidence on both sides that cheating will be punished; this increases the likelihood of long-term cooperation. An international organization, such as the IMF, can further incentivize cooperation by monitoring compliance with agreements and reporting third countries of the violations. Monitoring by international agencies may be needed to detect non-tariff barriers, which are disguised attempts at creating trade barriers.