Countries have trade barriers due to many reasons. Some include:
Protecting domestic farmers from outside competition
To prevent loss of unemployment
Sometimes for the purpose of National security
To avoid excessive imports
Sometimes it is done as a retaliatory measure to counter any willful diversion from pact with another country
To protect domestic economy from dumping of merchandise from other countries.