All of these countries, like everywhere else, started with with child labor. The difference is that the countries who no longer need it are almost universally capitalist.
Of course capitalism doesn’t eliminate child labor overnight. Villages in Pakistan and to a lesser extent China would starve to death if you eliminated child labor overnight. But capitalism is the only system that has proven capable of nearly eliminating it from a society over time.