Many do. The downside is that a heavy import tax makes whatever is being imported more expensive for local consumers to buy. In some sense this makes them poorer.
The goal is usually to encourage local firms to grow and compete, and sometimes that happens (e.g. Hyundai). But sometimes the local firms become complacent in their walled garden (e.g. Hindustan Motors).
You get ignored by lots of international companies that dont want to play by your silly and often unprofitable rules. Leading to a loss of choice and quality in goods and services, and a general depression of the economy over time. The softer hand moves more grain or something.
Revenge in the form of trade wars that screw everyone in the end. Exactly what the US is doing right now with all its tariffs, which are not helping US manufacturers (their stated intent) and are hurting US consumers (due to revenge tariffs).
Strong government management of the economy was the foundation for the success of Japan, South Korea, and Singapore in the mid 20th century (as an example). So absolutely people do it.
It is just the result of protectionism.