Before the civil war, the Soviets supported both, they sent advisors both the CCP and the KMT, and ordered CCP to cooperate with the KMT as well as to join the KMT. The KMT was built on Leninist organizational lines by Mikhail Borodin, a Soviet comintern advisor, a structure which was to last until the 1990s.
However, in 1927, Chiang decided that the CCP have became too influential and too powerful, and thus ordered them to be purged. This occurred near the conclusion of the northern expedition, a joint KMT-CCP military campaign to reunify the country from the warlords. One of the seminal moments in the northern expedition was the capture of Shanghai, which had many Communists in it as it had one of the largest proletariat population in China at the time. Indeed the city fell because the Communists staged an armed uprising in support of the northern expedition, seizing the city before the nationalist army arrived.
Chiang made deals with criminal gangs in the city to identify and eliminate the Communist party cells in the city, and in that they were extremely successful. In April, Communist party cells in Shanghai were purged completely and brutally, party members and sympathetic trade unionists were summarily executed or imprisoned. In the following year, hundreds of thousands Communists were killed and the CCP was all but wiped out in urban areas. The CCP was greatly weakened as a viable force and was forced to flee to the countryside
The Soviet Union still did support the Communists, such as allowing Communists to train in the Soviet Union and sending them back to the CCP. However, as Japan started to attack China in the 1930s, it made sense for them to aid the nationalists because they were the legitimate government of China and controlled far more territories and are therefore better equipped to fight the Japanese. Aid to the KMT took place in the form of actions like operation Zet, in which "volunteer" Soviet pilots and airplanes arrived in China to help defend against Japanese bombers. During the war the Communists were able to recover much of their strength.
At the end of WW2, the Soviets drove the Japanese out of Manchuria and handed much of it over to the CCP, it provided the base of operations the CCP eventually use to take the rest of the country in the late 1940s.
Throughout this period the Soviet policy towards China was quite pragmatic, and tended to support whichever factions would benefit their realpolitik interests the most.