To understand Japan’s seemingly irrational actions, you must look at its history.
For almost all of its existence, China and Korea saw it as a backwards island. Japan also had an inferiority complex: it refused to pay tribute to China, and launched a very foolish attempt to conquer China under Hideyoshi.
All of a sudden, Japan was handed a golden opportunity. China refused to industrialize, while Japan had no choice but to industrialize.
An island that was long down upon by its neighbors was now able to bully them around. When Japan’s inferiority complex came into the mix, all bets were off. They were going to do ANYTHING possible to make their superpower dreams come true.
The only way they could become that superpower was through the West. Much like how the British isles were once seen as a land of barbarism by the Romans, Japan wanted to copy that blueprint and create an Asian empire. Japan had no issue allying with the West since it was the only way they could subjugate Asia. After WW2, Japan was further Westernized under the brief American occupation. They adopted more Western concepts like women’s suffrage and an export-driven economy.
For Japan, the West was the only one who saw Japanese as the “master race” of Asia. Now that China has progressed and Japan has stagnated, Japan’s inferiority complex is flaring stronger than ever before. The Japanese government is comprised of the descendants of high officials during Imperial Japan, and yearn for the time when Japan was the “master race” of Asia. As such, Japan would rather be taken advantage of by the US than accept they are no longer superior to China.