The Japanese attack at Pearl Harbor was the result of information provided to the war ministry by Adm. Isoruku Yamamoto who had studied in the U.S. and spoke fluent English. Yamamoto had a low opinion of the U.S. navy, stating that its officer corps were little more than golfers and bridge players. He also said that the U.S. did not have the warrior heritage that the Japanese possessed (Samurai knights.) Yamamoto's argument was that the people of the U.S. would not have the stomach for a long war; and that if the Pacific Fleet were eliminated, Japan could most likely secure peace with the U.S. before the Atlantic Fleet could be deployed to the Pacific. Of course, much of the Fleet was at sea and was spared from the attack.
More importantly, Yamamoto advised that a formal declaration of war should be issued BEFORE the attack commenced. Unfortunately, the Japanese planned the attack to closely to the war declaration, and the message to Secretary of State Cordell Hull was not delivered until the attack was already underway; a significant miscalculation in timing. So, Japan's major blunder was allowing the attack to go forward before a formal declaration of war. The U.S. response was similar to that of President James K. Polk in his war message to Congress in 1848:
American blood has been shed on American soil.
The Japanese thought (or at least hoped) that the US response to the attack on Pearl Harbor would be fairly passive. They hoped that the US would decide that it was not worth it to rebuild their fleet and work their way across the Pacific to retake Guam and the Philippines and eventually to attack Japan.
This was, of course, a miscalculation (although it would be interesting to be able to know how the US would have reacted if its aircraft carriers had been destroyed at Pearl Harbor). Instead of deciding that it was not worth it to fight back, Americans were absolutely outraged. They enlisted in the military in droves and then mobilized the resources of the country to fight back against Japan (and the other Axis nations).