Mostly, and we did gradually and aggressively annex, take, buy, colonize and force out. At the same time there were ideals here competing against all of that. There were people protesting it and who knew and argued what was wrong with it. Maybe what finally got everyone's attention was the way weapons got so much deadlier and wars got so much more horrible. Either that or it was when the states reached the other side of the continent.
For the most part, our government was interested in expansion and economic gain. There was a dispute between factions over whether America should have a plantation economy or an industrial economy, but the industrialists eventually won out. Either way, many Americans were benefiting from this huge land rush, staking their claims and pushing further and further west. You're right that there were those who opposed it and protested against it, but it seems that their voices weren't really heard until the damage was already done. Hasn't that always been the case?
Our intention was to threaten them with invasion, and that threat worked. Why did our president think this was Ok? I haven't read about his opinions, so I don't know. We send an armada of steel ships and parked them just off of the coast within firing range. This was a bloody threat. This not only opened up Japan for trade but got the Japanese to upgrade their war machine. Perhaps that (upgrading Japan's military) was one of the US president's goals, but I don't know.
Not sure how an invasion of Japan would have worked out for us if we had tried. I don't think our leaders were thinking of anything that ambitious during the 19th century, and it would have been a disaster for us if they tried.
The US wasn't the only country interested in Japan. Part of what drove our government (along with other governments) was the state of the world at the time where multiple powers were competing and scrambling for territory to colonize/conquer and exploit for resources. Japan realized this, and they wanted in on the game as well. The U.S. was in a similar position, although we were far better off, resource-wise. But much of what we did was rooted in the idea that, if we didn't do it, someone else would. That doesn't make it okay, but it was the way of the world (and in many ways, it still is).
The Nazis were also fresh in our memory. They called themselves a socialist party. Everywhere socialism or communism went there was blood, backstabbing and more dictators. The USSR preached against capitalism, against religion, against all theism! Naturally this frightened people.
I don't agree with the idea that the Nazis were a "socialist party." Not only did they continue to allow profit and private ownership in the Third Reich (and even maintained contracts with US companies), they were declared, committed enemies of Communism and anything associated with it. This is how Hitler was able to gain absolute power, because of frightened people. The Germans were frightened of Communism and the USSR in the same way that many Americans were frightened of it.
The USSR preached against capitalism and religion because they saw them as harmful to the well-being of the common people. They also called for a world revolution, and there were Communist movements in multiple countries which shared similar beliefs. Keep in mind that WW1 was still fresh in people's memory, and that was a capitalist/imperialist/nationalist war, where millions of common people were set up as pawns to slaughter each other by malignant interests. It was especially bad in Russia, as they were losing badly to the Germans, their people were starving, and their Tsar was an incompetent buffoon who had no business attempting to lead troops in battle. I can't say that I blame them for wanting to overthrow the Tsar and quit the war.
Officially, the Soviet Constitution allowed freedom of religion, even though they discouraged religion.
During the 1920s and 30s, the USSR was not internationally aggressive, and in fact, Stalin shifted the emphasis to building socialism in the USSR and putting the idea of world revolution on the back burner. If an opportunity presented itself, he would take it, but it wasn't like he was going around looking for governments to convert. That started to change as Hitler grew into more and more of a threat. Just as the Germans were frightened of Communism, the Russians had good reason to be frightened of Nazism.
They also had good reason to be frightened of capitalists, too. Our pro-capitalist and other Western governments opposed them from the get go - even before they had a chance to do anything "evil." Even then, there was a progression of events which led to Stalin's rise and the atrocities attributed to him. Many of his victims were fellow Communists, and he would later be strongly denounced by his successor, Nikita Khrushchev. The Soviet Union went through a period of thaw after Stalin, and things gradually got better. Gorbachev implemented Glasnost and Perestroika, encouraging more freedom and openness. Unfortunately, the fall of Gorbachev and the Soviet Union was accelerated by an abortive hardline coup, leading to Yeltsin's rise and the Soviet Union (legally and mostly peacefully) voting itself out of existence.
So, there are Communists, and then there are Communists. They're not all the same; there's quite a difference between Stalin and Gorbachev. Or Stalin and Trotsky.
What if we judged capitalists the same way? The capitalists of the 19th century were truly a horrible lot. They were plantation owners, racists, slaveowners, mine owners, railroaders, robber barons, carpet baggers, sweatshop owners, exploiters of child labor. They were among those who expanded across the continent, rolling over anyone in their way (and they're the ones who stood to benefit the most from that expedition to Japan you mentioned). What if we judged capitalists by that, and only that? It would be a very ugly portrait, just as Communism is portrayed.
In any case, people might have just as much reason to be frightened of that.
It preached religion was a menace, and this bothered many religious Americans. It also horrified us in other ways. When the USSR people were starving (which happened multiple times due to the inept governmental structure), the soviet central government was sometimes too embarrassed to accept help. Rather than accept help it refused to admit problems existed and so let people suffer instead. It forbade its citizens to leave its borders! It blackballed anyone who spoke out against its group think! Its food distribution system was inept due to socialist failings involving centralized control of resources, the bottleneck which made graft deadly. Worse still, it was in a very cold climate where starvation more often resulted in death. The central government could never admit fault in things, and so problems continued to build. Americans heard about these things. They could hardly avoid hearing about them. The worse things got the more the USSR preached socialism both in their own country and in others. They outlawed religion and blocked out all information from leaving or entering their borders. Americans were horrified of course. Many believed socialism was of Satan and was Satan trying to get their children. It was to many of us Americans as satanic as nazism. Call this paranoia, but it was orchestrated by the Soviets. They wanted this an anti-God, anti-capitalist message to go out. They wanted people to know that they were going to defeat God and religion and capitalism.
I won't deny that their system had many problems, along with much brutality, atrocity, and suffering. It's easy to play the blame game and Monday morning quarterback and say "it's all the Bolsheviks fault," but all I can say is that the history you're addressing here is complicated, to say the least. I'm not saying they were a bunch of good guys, but I am saying that they weren't a threat to the United States. They had more of a reason to feel threatened by us than we ever did of them. Tying this back into the original topic, the creation of CENTO and SEATO came about due to fears of the Soviet Union, although they saw it as encirclement by the West designed to strategically isolate them. Iran was a member of CENTO, along with Iraq, Turkey, Pakistan, and the UK.
I guess a key question should be asked: Do we have the right to interfere in the internal affairs of other nations, all because many Americans were afraid that Satan was trying to get their children? We might be afraid of Stalin or socialists in Russia or China, but how does that give us the right to meddle in other nations which aren't Russia or China?
If Americans really wanted to stop the Communists from being a threat, then they should have listened to Patton and MacArthur back in the day. If we really did believe them to be so grave a threat, then that would have been the sensible thing to do at the time.
That we didn't can mean only one of two things: Either our leaders didn't really believe they were a threat (which would mean the entire basis for the Cold War and Red Scare was a lie), or they were a bunch of gutless cowards who made a pretense of "fighting communism" by slaughtering the small fry of the world and/or interfering in their internal affairs to some degree or another.
I don't know how many people were murdered or tortured under the Shah's regime, but part of the reason those people suffered as they did was because Americans were frightened of the USSR. But rather than deal with that directly, we decide to install a dictator to murder and torture Iranians. Because we were afraid of Stalin, we punish the Iranians? Is that supposed to make sense?