It wasn't. Japan only ever managed to occupy about a third of China's pre-war territory (I'm excluding Manchuria, Tibet and Xinjiang here), and indeed had never really intended to conquer China outright. See:
/u/hellcatfighter's answer on Japanese war aims, and
/u/parksungjun and /u/white_light-king on Chinese resistance against Japan.
Well it is important to conceptualize the theater in China as comparatively different than most theaters in WWII. Also, the combatants are also comparatively different.
Japan did occupy and hold territory, especially the eastern coastal areas and large cities. They however were highly tied to railroads due to the low amount of infrastructure throughout China. In preparation to deal with these limitations, Japan had a very medieval thinking on how to supply troops in the field with basics like food and water. They simply planned to plunder (known by the euphemism "forage") the countryside. Foraging was completely inadequate for supplying a modern army due to how the modern armed forces need to operate within an area. Simply sending out bands of foragers made them easy targets for Chinese guerrilla fighters. That, combined with other needed supplies like ammo, essentially tied the Japanese front to the railway system in China, limiting its capability to push inland. Whereas China could operate more effectively around the railroads because they held the surplus food producing areas of China and had local systems of transportation and support. For example, picture traders with pack animals bringing guns and ammo to China. Japan could not use these systems in China like they did in the first Sino-Japanese war, due to increased local resentment of the Japanese and the brutality of the Japanese military. However, Japan had adopted modern organizational structures to be able to organize a more effective fighting force with less resources.
China had only recently adopted western organizational structures, and even did so while mired in a long civil war between the Communists and Nationalists. Simply, China had huge amounts of manpower and resources at their disposal, but did not have the ability to organize that manpower nor make the war material necessary to combat the comparatively smaller Japan. Japan had just gone through a period of modernization 70 years prior. They were able to effectively mobilize huge portions of their own population, which was not tiny and in comparative size to Germany. Japan also built the industry to be able to produce arms domestically, whereas China needed to buy guns from overseas. Transportation from overseas limited the size of guns China could get, meaning China rarely had large amounts of artillery with tanks being even rarer. Doubly bad for China was the prior civil war that hindered the organization of its resources and manpower. Japan had a much smaller resource and manpower base, but could organize far more of it, and also use it more effectively, than the much larger China.
Lastly, Japanese troops were far more effective than Chinese troops due to Japan's long prior effort to construct a modern army combined with their better material condition. Many Chinese troops were only sent into battle with small arms and, if they were lucky, some mortars for artillery. China essentially fought a guerrilla war, wearing down the Japanese over time. They would do large pushes into the Japanese lines, but did so in a limited way to cut off Japanese supply lines, and also keep their own routes to Allied help open. Japan would go into battle with hungry troops, that at least had artillery and machine guns. Chinese troops would often go to battle with little ammunition, maybe mortars, and sometimes without shoes.
Japan had a high ability to mobilize its limited manpower, an effective use of its limited resources, and a superior military. China had vast amounts of manpower and a somewhat less vast amount of resources, with a very limited ability to mobilize them into an effective fighting force. However, Japan was highly limited in controlling the size and scope of China's landmass, being relegated to China's railway system. The local hostility to Japan, one that was not present during the first Sino-Japanese war, also made resupply limited. Japan simply had no way of getting enough supplies to enough troops in order to firmly collapse the Chinese combatants, and therefore, got bogged down in an endless war with no clear winners.