Why didn't the US make any attempt to stop communism in China? Well, they totally did! Just not only the same level as Korea and Vietnam. US involvement in the Chinese Civil War (1945-1949) was in the form of massive material and monetary support to the KMT government of Chiang Kai-shek, who was the President of the Republic of China. At the beginning, Chiang had more men and better equipment and was in a favorable position to win, but owing to a host of reasons which I went over here, he was ultimately defeated. The fall of China to Communism led to the debate known as "Who Lost China?" and prompted the Truman administration to issue the 1949 China White Paper to explain why the KMT lost. According to the State Department:
In August of 1949, the Truman administration published the “China White Paper,” which explained past U.S. policy toward China based upon the principle that only Chinese forces could determine the outcome of their civil war. Unfortunately for Truman, this step failed to protect his administration from charges of having “lost” China.
For many, the "loss" of China (a flawed theory, since the US did not own China) was seen as totally avoidable. At the same time, there was the rise of the Domino Theory, which stated that if one nation fell to Communism, the nations on its periphery would also fall. All these reasons factored into the direct US response to North Korea's invasion of the south.