Mao Zedong and the Chinese Communist Party(CCP) were able to gain control because of many reasons. Almost all the Chinese people living under Chiang Kaishek's rule weren't happy because of high taxes, accusations and chaotic life. Many people under GuoMingDan(GMD) rule left to live under CCP rule where there were lower taxes. Peasants especially were attracted to CCP rule because the land was distributed fairly and people gave them self-respect. The red army protected communists, peasants liked the interest free loans and rents were reduced.
CCP popularity was growing because people felt Chiang Kaishek was doing a good job because he was ignoring Japanese invasion and was battling against the CCP, people felt getting rid of foreign exploitation was more important than fighting their own people, the Chinese.
In 1936, Zhang Xueliang, son of Zhang Zuolin by now had got rid of his drug addiction and he wanted to fight the Japanese.
He took Chiang as a prisoner and persuaded him to join with the CCP to fight the Japanese. In the end Chiang was set free and he agreed to work with the CCP and formed 'The United Front'
Japan attacked China because it's population; industry and military were growing fast. Japan was an island and needed more space for it's growing power so they needed to take China's land. By 1927, Japan had control over Manchuria's economy; Machuria had rich natural resources and a small population.
I think the most important factor was the economic factors because in 1929, the Wall Street crash which hit Japanese economy hard therefore they attacked Manchuria in 1931. The CCP had used clever tactics because the Japanese didn't have enough men to guard the places they had taken, the CCP moved in and took control, these places were liberation areas.