The most important reason why China was able to contain it, was that it was concentrated in one Chinese region. This region represents only about 5% of Chinese population. Isolating them from the rest, then rigourously testing elsewhere - where the proportion of cases was 0.00...cinco% of the population - did the rest. Unfortunately, in Italy and other countries, the virus was able to fly under the radar and rapidly spread before alarm bells went off. China dropped the ball early, most other countries as well - but the fortunate thing for China was that the spread was still minor in comparison to its population and area, whereas in Italy and other countries, the spread was much more heterogeneous. The early-stage testing wasn't huge in China. In fact, they were only were able to test 200 samples a day in Wuhan until fairly late in January (this is what a Chinese colleague tells me). But like I said, with a spread that was still localized, it helped a lot to lock these people up. Then you give yourself time to ramp up testing elsewhere.
Compare to the situation in my country, Belgium. About 1500 positive cases per day. That would equate to about 200.000 new positives every day in China. Do you think they would be able to eliminate or contain the virus then? Of course not, too late. Flatten the curve is all we can do. Hospitals are coping well, still only at 55% capacity, and new hospital admissions seem to be starting to slow down. Different strategy than China, but impossible to do anything else. Next week, we will carry out 10.000 tests/day, which would be comparable to China doing 1.5 million a day, but even that is not enough to fully cover all bases.
The most important thing we should've done, in hindsight, is cancel all flights from China the same time Wuhan was closed off, and test all the people that had come in from China the week prior. Ironically, WHO and China both told the world not to halt flights to and from China. Many governments made capital errors. I don't think anyone can (and should) claim clear high ground at this point. Also, pointing fingers is not very helpful either - that bill should be settled later (with substantial proof, i.e. not some dodgy leaked security info in Bloomberg).