Ok so a friend of mine told me that the only reason Japan surrendered was because of nukes and they were actually defeating USA. Is this true? Could they have done this considering that Soviet Union would come for? Also isn't USA huge? Wouldn't have been a logistical nightmare to control an occupied territory as big as that?
tl;dr: No, Japan had essentially no hope of defeating the United States in a protracted war -- the type that the Pacific campaign turned into. Upon entering the war, the "strategy" that Japanese leadership had settled on was that their best hope was to win a quick and decisive victory against the American fleet, after which Washington would (in their view) forced to sue for peace. Instead, their "decisive" strike on Pearl Harbor, taking the form of a surprise attack, failed to damage the Pacific Fleet's aircraft carriers, and massively increased American resolve to win the war. American industrial output dwarfed Japanese; as one point of comparison, the US Navy launched 100 aircraft carriers (of all types) during the war while Japan produced 13, including converting two ocean liners to ships of dubious value. And it's not clear that the atomic bombings of Hiroshima and Nagasaki eventually forced Japan to surrender; there are multiple other factors, including the Soviet invasion of Manchuria, that are cited as reasons for surrender.
The longer version, adapted from some earlier answers that I'll link below:
First off, there's no possible way that Japan could have invaded the mainland US or even Hawaii. The planned Midway invasion would probably realistically have been beyond the reach of the Japanese fleet train to sustain anything but a shoestring garrison, and in any case Midway was meant to draw the American fleet out to force it into a decisive battle, only secondarily to occupy territory.
That last point gets to the meat of your question. Japan was quite aware that a long war against the U.S. was not winnable. Their war aims were to secure the resources of Southeast Asia (in particular oil, but also rubber and other industrial supplies). They couldn't do that with a U.S. presence in the Philippines. So their overall war plan, which saw successive revisions throughout the decades before 1941, was to quickly defeat colonial powers in Southeast Asia, and to build a defensive perimeter that the U.S. fleet would be attrited by before a final annihilating battle, after which the U.S. would sue for peace. The idea was that the American fleet, steaming west, would have to face Japanese air power and submarine attacks before making it to the vicinity of the Philippines or the home islands, where it would be decisively beaten.
To that end, the Japanese fleet's composition emphasized quality over quantity; they trained very elite naval aviators, for example, but very few of them. They also emphasized night fighting, the use of torpedoes, and an offensive spirit that was reckless and dashing, all to overcome numerical weakness that was inevitable given the two countries' industrial bases. At the start of the war, the Japanese arguably had the finest air fleet in the world, absolutely had the largest battleships, and had unparalleled torpedo technology.
In the immediate run-up to WWII, the Japanese naval leadership conceived the plan of striking the Pacific fleet in Pearl Harbor at the same time as planned strikes on US, Dutch and British possessions in the Philippines and elsewhere. The Pearl Harbor attack was inspired partly by the British raid on Taranto, and was designed to cripple the U.S. fleet in harbor to win the Japanese extra time to build that defensive perimeter. To say that the political leadership underestimated America's resolve for a long war is an understatement.
###What happened after Pearl Harbor?
Once the Pearl Harbor attack was a success, Japan followed up on that with operations between December 1941 and February 1942 that included an invasion of the Philippines, an invasion of the Malay Peninsula that resulted in the fall of Singapore (the so-called "Gibraltar of the East," thought to be impregnable) and invasions of Borneo, Celebes and Ceram to capture oil fields and strategic spots. By mid-February they had broken the so-called "Malay Barrier" of Allied resistance, being only opposed by a scratch fleet of Australian, British, Dutch and American ships with no air support to speak of (the "ABDA" command was plagued with problems, including the Dutch admiral in charge not speaking English), and had raided Darwin with carrier planes. The ABDA Command was totally broken by March, after which the Japanese fast carrier fleet sortied into the Indian Ocean and raided Colombo, Trincomalee and Batticaloa. The raids destroyed aircraft on the ground, and in the fighting the British also lost 7 warships (including the carrier HMS Hermes), 23 merchant ships and around 40 aircraft, all for the loss of about 20 planes on the Japanese side. The British fleet retreated to the west side of India in hopes of protecting trade routes to the Persian Gulf and Red Sea/Suez Canal.
The problem for Japan after winning that string of victories is that they had pushed their defensive perimeter out from Japan, and garnered significant access to oil and other resources, but they still hadn't destroyed the American fleet, and weren't quite sure of the best way to do so.
Which leads us to ...