There are two main reasons for this.
First, the war ended in a stalemate because of Chinese involvement. The Chinese had a huge army that was able to balance out the UN forces and push them back down the peninsula after they had made it as far as the Yalu River which was the border with China.
A second possible reason is that the US did not want to pursue an all-out war against China. Douglas MacArthur, for example, wanted to attack China directly, possibly using nuclear weapons. President Truman, though, did not want to bring on a major war by doing this. The US's desire to keep the war limited in scope is another reason why the war ended in a deadlock.