So many times in history, an event or a movement is only recognized after the fact. That was not particularly the case with the Soviet Union after World War II. We (America) watched the signs and the encroachments (some of which are mentioned above) and developed the containment policy to keep the Communist movement at bay. In broad terms, we saw it coming and were ready to combat and contain it.
And we have to give a shout out to George F. Kennan, an American diplomat who had been working in Moscow almost since the Russian Revolution who sent his now famous "Long Telegram" to President Truman, advising him in how to deal with the Soviets. He advised (paraphrasing here) that the Soviets only understood the threat of force. He argued that they were aggressive, yet pragmatic. Containment policy was designed with this in mind - make allies and alliances so that containment is an obvious and open policy, and station your troops and forces in such a way that it can be followed through with if need be. He also stated that directly threatening the Soviets would be counterproductive.
As stated above the Soviet Union was set on spreading Communism to as many places as possible. Once the United States realized this the response was to work to contain the spread of Communism.
The U.S., United Kingdom, and the Soviet Union were allied in the war to defeat against Nazi Germany. However, after Germany's surrender it became clear that these nations would also lead the rebuilding effort in Europe. As a result the 'Big Three' held two conferences in 1945. The Yalta and Potsdam Conferences designed a plan, a set of agreements to stabilize Europe's political and economic affairs. Unfortunately, soon after the conferences it became clear to Truman and Churchill that Stalin was not planning on keeping his part in the agreements, especially when it came to holding free elections in Poland and for that matter Germany. In addition, Stalin's troops were still occupying Poland in more than a peace keeping capacity. When Truman and Churchill confronted Stalin regarding this he refused to move the troops. It became evident to both nations that the Soviet Union had not intended to adhere to the Yalta and Potsdam agreements. These actions led the U.S. to a shift in foreign policy, which included stopping the spread of communism. The Containment Policy was adopted in order to promote democratic efforts in a post war Europe. Several provisions provided economic aid for rebuilding as well as initiatives for the weakened nations to resist communist threats.
As the conflict with the USSR mounted, it led the Americans to be more afraid of the possiblity of Soviet domination of the entire world. This fear grew as, for example, China became communist and North Korea invaded South Korea.
As America started to fear Soviet domination more and more, the policy of containment developed.