Short answer which can no doubt be expanded on by others with more knowledge and time: Treaty's and attitudes.
Anglo-Japanese Alliance between UK and Japan was signed in 1902 and ended in 1923 Explains why Japan fought in the first war and was not bound in the second.
Washington Navel Treaty and subsequent agreements treated Japan as a second rate power compared to UK and USA.
In the founding of the League of Nations, Australia and other countries including USA were uncomfortable with a Racial equality clause that the Japanese wanted included and voted against it. Yes, Racial Equality.
These slights and the League of Nations reaction to the Japanese Invasion of China in 1931 left Japan, a country who only recently had stepped out of isolation, outside again. With a whole world not interested in treating her equally.
And remember, the second world war for Japan wasn't so much about fighting against the UK or America but claiming what she considered her right, to rule over Asia as the Europeans did with the rest of the world. The Europeans and Americans were just in the way, and had to be dealt with first.