In developing countries, why do governments intervene in trade and investment?
There can be at least two reasons for this.
First, it is sometimes the case that governments in such countries are corrupt. They intervene in the economy in the ways you mention so as to reward their friends or those who bribe them.
Second, governments in developing countries often believe in the "infant industries" argument for protectionism. They believe that they need to limit trade and perhaps direct investment within the country to industries that they think will be important for the country in the future. They intervene in trade and investment so as to help those industries grow because they hope those industries will form the backbone of their economy in the future.