Technically, under Code 213 and 215 of the Chinese Criminal Law Code, Counterfeiting is Illegal...
...But, the de facto reality is that India Whiskey Charlie is right, counterfeiting is basically never prosecuted. Counterfeiting is a widespread problem in China, where individual profiteers decide to take on a risk in the hopes that they will not be caught. Much like the cocaine drug industry, big drug manufacturers use a number of small "dealers" and "pushers" to distribute the products. In China, factories use a number of dealers and pushers to distribute the counterfeit goods. These individuals may get caught and fined. But the source, being the factory, is sometimes unknown. Also, some would argue that the source isn't well hidden. There are entire cities where numerous factories specialize in producing counterfeit goods. The authorities are aware. But like a whack-a-mole process, it's very difficult to apprehend the real culprit. Lastly, some manufacturers don't even know they're counterfeiting. Some factories are approached by people who commission them to make thousands of an item. Sometimes hiring multiple factories to make the parts. So this way, no factory realizes they're counterfeiting a complete product. The people commissioning these parts go through the standard Request For Proposal (RFP) and Request For Quote (RFQ) process making them appear legitimate!
Fines for counterfeiters are quite small. For instance, a caught counterfeiter can be held to up to 5X of the revenue loss by the accuser. But these are difficult to prove in a court of law. As it's not like the factory is going to offer their production numbers of how many fakes they made. And the owners of these factories are hidden through layers of shell companies, so it's difficult to find an actual individual to prosecute sometimes.