What caused a relatively small nation - Japan - to attack a large and powerful nation like the U.S.? The sequence of events is worth remembering. A modernizing Asian nation, Japan sought to acquire an empire like those still held by Britain and France. It did so by invading China, which fought back.
Western nations regarded this act as unacceptable, viewing China as an ally of sorts, and imposed economic sanctions on Japan. Japan viewed the sanctions as potentially crippling and at minimum as frustrating their aims at building an empire.
Already on a semi-war footing, as a result of invading China, the military was very powerful in Japan and believed a military response to U.S. sanctions called for. Hence the attack, which proved successful tactically but strategically calamitous for Japan a few years later.
-----------
One can imagine a similar scenario playing out over Taiwan, with China. China invades Taiwan, in response the U.S. ceases all trade with China. Facing economic depression or worse, the CCP militarily attacks the U.S.
At the end of the day, this outcome would probably result in millions dead in both countries. And similarly, China would likely come out worse than the U.S. This scenario seems almost inevitable, and yet massively regrettable nonetheless.