I realize that it might be a kind of naive question to ask why a country did not attack another country. But wouldn't it have been a huge opportunity for the US to establish a western world order? Moreover, they could have prevented the Cold War and the current conflict in the Ukraine.
The alliance between the US and the Soviets was more of a purpose alliance. They only fought together because they thought Hitler was the greater danger. I believe that it must have been clear that, after the axis powers were beaten, there would be conflicts between the US and the Soviets.
The Cold War was so dangerous because two nuclear superpowers were facing eachother. The Soviets tested their first nuclear weapon not before 1949 though. Also, the Soviets military was weakened much more than the US military in WWII.
So I conclude that 1945, right after Germany and Japans capitulation, would have been the perfect moment for the US to attack the Soviet Union, eluminate Communism and create a western world order. Why didn't they do it?
It's a common misconception that the US, from 1945 onward, could have easily taken on the USSR with nuclear weapons.
The sum total nuclear weapons we had ready to use at the end of 1945 was... zero. We had the fissile material for maybe two bombs. But we'd have to assemble them (they were still crude, hand-assembled weapons), then move B-29s into shooting range, then get the operations together to make them work, then hope the Soviets didn't try to shoot them down... it would have been non-trivial.
And again, we had at most two that we could have used. So we drop those on, say, Moscow, and then what? The Soviet tanks start ramming across Europe, Asia. The world community may not be thrilled about our having started a new war. Imagine World War II with maybe another atomic bomb every month or so. Would that be enough to stop Stalin?
How many nukes would we need to take out the entire USSR in one fell swoop? More than we had until 1950 or so. See here for minimum and optimal estimates made in late 1945.
Could we have increased our bomb production? Not easily. The Hanford piles were actually about to be taken offline, because they had structural defects (they ran at half-WWII-power until mid-1948, producing between 0.6 and 1.75 bomb cores a month in this time). Enriched uranium from Oak Ridge was increasing production but they had not engineered an HEU-only implosion bomb, so you're talking about really slow production of crude "Little Boy" style bombs. (The first composite HEU-Pu implosion bombs were not produced until 1948.) So up until 1948 the US still had only around 100 total weapons cores, and they were still using essentially the same bomb designs as they had developed in WWII. (All this changed around 1949-1950, but by then, the Soviets had nukes. Which arguably might not have mattered too much, since they didn't have many nukes. But that is a separate question.)
So any immediate war would look a lot like WWII — where the Red Army's numerical advantages would be huge assets — punctuated by the occasional use of a nuke. It would have been ugly.
Although you specifically mention the US in your question, I want to bring the British into the equation because they really did consider this question in 1945. As the war in Europe was coming to a close in 1945 Winston Churchill ordered the creation of a battle plan for a potential war against the Soviet Union, to be theoretically launched upon the defeat of Germany by the other Allied powers (including the United States). Recognizing the threat that the Soviet Union and Stalin posed to both Europe and the world, Churchill wanted to launch a surprise attack in order to force Stalin to honor his commitments to the post-war European order. The codename for the operation was aptly dubbed 'Operation Unthinkable'.
Essentially, the plan was abandoned because the odds of success were deemed to be nearly impossible. This is largely due to the Soviets holding roughly a 3:1 numerical superiority on the ground in Europe. This 3:1 superiority is counting the combined strength of the British, American, French, Canadian, AND Polish forces. While the Allies may have had the element of surprise in their initial assaults, maintaining a sustained conflict against such a massively stronger opponent would not be possible. You also have to consider the fact that after the defeat of Japan winter would be a few months away, only further complicating matters for the Allied forces in any conflict lasting more than a few months.
It's not as simple as this.
Contrary to popular belief in the US, the Soviet Union were the primary force behind Hitler's defeat, not the US/British/French/etc forces. Just look at the war dead:
USA: 420,000 UK: 450,000 France: 550,000
The Soviet Union? 21 to 28 million.
Nazi Germany? 7 to 9 million.
source: http://en.wikipedia.org/wiki/World_War_II_casualties
Stalin had a huge advantage at the Yalta and Potsdam conferences because of their immense contribution to the war effort. For example, the Allies agreed to the forced repatriation of Soviet citizens from lands that the USSR occupied, leading to the deaths of many thousands of people who were viewed as traitors to the Soviet cause. See the betrayal of the Lienz Cossacks for a prime example here.
The degree of leverage that Stalin had over these conferences reflects the immense influence he had over the negotiations, and more poignantly, the degree to which Western leaders respected and feared him. Nobody dared cross Stalin.
I'm at work and I can't find my stats on how many troops were active from each nation at the end of World War 2, if someone can back me up I'll edit my post. But I'm quite certain the USSR had a substantially larger force occupying Eastern Europe than the Western Allies did. The Western Allied forces were unable and largely unwilling to turn the already-catastrophic Second World War into another all-out multi-year campaign against the USSR. Besides, it did not become apparent for a few years (with the Soviet refusal to allow free elections in the GDR, etc) that the Soviets were going to retain control over Eastern Europe. So thus, the Iron Curtain didn't really descend on Europe until '49 or so, by which time the Marshall Plan was in full effect - Europe was on the road to recovery, and had little appetite for a second all-out war.
In addition, the Soviets believed the capitalist nations would experience an economic collapse as they attempt to re-adjust to the postwar period. The allies were also not certain that they would manage a successful economic transition, and remained cautious.
Finally, the Soviets did not want to provoke war because they feared the US' atomic weapons capability, and the western powers understood that the threat of the nuke would keep the Soviets from provoking war.
It must be noted that the second red scare didn't begin until the 1950s. I do not know specifically, but OP, you seem to believe that USA and USSR were some kind of enemies turned uneasy allies during the war. Relations between the nations were very different before and after the war.
Attacking the USSR would have caused big political problems. First of all, USSR was not in a very bad light in many parts of Europe yet as it would be later. Even though there was a lot anti-stalinism, he was still alive and his worst crimes weren't so much common knowledge as it is today. USSR was a big part of the allied forces, and their contribution should not be underestimated (D-day wasn't the only turning point as the movies would like you to believe).
Not counting in the USSR in the equation, starting a war right after one of the most horrible wars in history, with a battle weary population ... that's not gonna get you political points.
Besides military statistics, the political implications of attacking USSR would have been gruesome.
Its been mentioned, but the US under Truman didn't immediately see the USSR as a major threat, and only shifted its position later on.
I'll refer to a post I made a few weeks ago regarding the "Long Telegram", which in part helped change the Truman Administration's view towards the USSR:
If you haven't, I'd suggest reading George Kennan's "Long Telegram." Kennan was the deputy chief of staff at the American Embassy in Moscow immediately after the Second World War (and would later serve as Ambassador). In 1946 he was not happy with the way Truman was planning on handling the Soviet Union, so he sent a message (the aforementioned Long Telegram) explaining that rather than cooperate with the Soviets, the US should contain the spread of communism.
When that failed to gain notice, he published a longer version in the July 1947 edition of Foreign Affairs, titled "The Sources of Soviet Conduct" and under the pseudonym of "X". It largely set forth the official American policy towards the Soviet Union in the early stages of the Cold War, namely containment within Europe, and is arguably one of the most important documents regarding it. The two essays are not terribly long, and both are linked above for convenience. They will help give an idea of both the US and USSR's stance at the start of the Cold War, and the view of people who set forth how it was going to be.
Was the USSR even actually a threat to the United States? It was always my understanding that the "communism" spectre was never really an issue, and it was just a good, believable reason to make less-informed people do what the government says or be complacent in its military's awful overseas activity. The fact that we had people spying on them the entire time leads me to believe the US knew a lot more about how terribly the USSR was really doing (as far as the vast majority of their people were concerned) than their propaganda department would have liked us to believe.
edit: Was the United States really ever out to create a "Western world order"? Before World War I and II, it seemed like the US really just wanted to stay the hell out of everybody's business in the world, but after those horrible atrocities maybe the US felt like they needed to do something to ensure it would never happen again. It's not really about creating a new kind of authority, it's just about avoiding a situation where millions of people kill each other over the span of about 30 years (combining the two wars). If this is true, the answer to your question could potentially be "because they didn't want to fight more, they wanted to fight less"...it would seem plausible given the US also initiated the United Nations and gave it such powers to help prevent conflicts like this.