If protectionism is injurious to a state, is the success of mercantilist China in spite of its protectionist measures? If protectionism is injurious to a state, is the success of mercantilist China in spite of its protectionist measures?

Furthermore, if the academic consensus is that most instances of protectionism are akin to using self-harm in retaliation to a perceived offensive measure, why is it still so prevalent (for example the EU Common Agricultural Policy)?

References:


  Protectionism is used for a number of reasons, some of which are
  outlined here, but is generally acknowledged to be ineffective and
  harmful to a country’s economic interests in the longer term. This is
  because it prevents the mutual gains from trade being realised, and,
  by restricting competition, limits the incentives for firms to improve
  their efficiency.


https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/43315/11-718-protectionism.pdf


  Our main conclusion is that, in all the scenarios we consider,
  protectionism is not an effective tool for macroeconomic stimulus.


https://www.nber.org/papers/w24353
I am not an expert on this issue, but pending an expert's answer on this matter, here are my two cents.

1. It is not true that there is a consensus that protectionism is almost always a bad thing for a country.

Many slightly non-orthodox economists (e.g. Dani Rodrik, Chang Ha-Joon) have pointed out that protectionism is a perfectly good strategy that many developing/industrializing countries have adopted, including the US in the 19th century, Japan and Korea in the 20th, and now China in the 21st.

I believe Rodrik and Chang's main argument for protectionism in this context is the infant industry argument. Another argument is the second-best argument. See this other answer of mine.

2. China's protectionism has been selective.

In my vague impression as a non-expert, in most industries in which China exports heavily (except perhaps steel), there has been little protection and great competition. Think for example of clothing and the electronics manufacturing base centered around the Pearl River Delta and Shenzhen. These are industries in which every cost advantage and innovation are ruthlessly and instantly seized upon, to the advantage of both producers and consumers (including consumers around the world).

I believe the IT industry is where China engages most heavily in protectionism. As is well known to the man on the street, many technology platforms like Google, Facebook, and YouTube do not operate in China either because they have been outright banned or because of the onerous censorship requirements. The result is that local substitutes have flourished (Baidu/Sogou for search, WeChat/Weibo/QQ for social media, Tudou for video, Taobao/Alibaba for ecommerce) and Tencent and Alibaba are among the worlds largest firms, even though most people outside China may know little of them.

But perhaps the greater bone of contention is China's "theft" of intellectual property (IP). As an explicit/implicit condition of entry, tech firms trying to enter China are usually forced to hand over their IP. 

Again, these are merely my vague impressions and hopefully an expert can back these up or correct me with more concrete facts and statistics.

3. One argument against protectionism is that it provokes retaliation, which can be damaging.

However, for the past many decades, the many countries to which China exports have shown great restraint and retaliated little. These are for reasons that I am not sure about and which I hope an expert will explain. (Perhaps this is simply the same restraint that has been somewhat shown -- not always consistently and often arbitrarily -- to other developing countries in the past.)

This is now changing with the aggressive trade war launched by Trump and there are now indeed fears and perhaps even signs that China may be suffering as a result of this trade war. Huawei and ZTE are two Chinese companies that have suffered heavily from the US's uncertain on-and-off bans in the past year.

This however is to not to say that Trump's trade war is the best approach. See for example this recent piece by the right-wing, pro-trade Cato Institute ("Disciplining China’s Trade Practices at the WTO - How WTO Complaints Can Help Make China More Market-Oriented", Nov 2018). I think many economists would agree that if China does indeed engage in protectionism and one wishes to retaliate, then the means of retaliation should be through multilateral, rules-based organizations like the WTO, and not unilateral, arbitrary trade wars such as those currently being undertaken by Trump.

4. Your example of the EU Common Agricultural Policy.

I think economists are almost universally agreed that protection for agriculture in rich countries is bad for most parties (the only beneficiaries being the farmers who receive the subsidies). I have never come across any modern economist defending any such policies.

Besides, I am not aware that China engage in much agricultural protectionism and indeed, I don't think this is what people think of when talking of China's protectionism. (Recently China has imposed heavier tariffs on pork and soybeans imports from the US, but these I believe are merely strategic retaliatory measures against Trump's trade war.)