When governments practice protectionism (restricting or banning imports), they are typically trying to improve their own domestic economies.
Many governments feel that imports compete unfairly with domestic products. In developed countries like the US, governments often feel that imports have an unfair advantage because of the low costs of labor in developing countries. Governments in countries that aren't so rich feel that their domestic industries can't compete because industries in more developed countries have had a head start in the race. In both cases, this leads to a desire to protect domestic industries from competition. Governments feel that their own industries will then be able to produce more goods and make more money. This would, they feel, help their domestic economies.
There are other reasons for protectionism, but this is the most important reason for it.