I mean they weren’t a huge power, they lost the war after all. But I understand what you mean – the Japanese were significantly more industrialized and organized than, say, China at the time of the war. The reasons for this have to do with events in the 19th century.
In 1853 an American expedition arrived in Japan and convinced the Japanese government – with just a little teensy threat of war – to end their policy of isolationism and sign a trade treaty that would open their ports to the US and other countries. This was a huge shock to the samurai class who had become pretty complacent with the situation over 200 years of peace and isolation. Suddenly Japan was under threat of invasion and the Japanese understood that the only way to survive would be to massively spend on defense, learn to use western weapons, and modernize as fast as possible. This was not uncontroversial, of course, but luckily for the Japanese there was a class of young Samurai like [fukuzawa yukichi](https://en.wikipedia.org/wiki/Fukuzawa_Yukichi) who, while they had very little actual contact with foreigners, had had an interest in foreign languages and importing foreign books for some time. This relatively educated class was well-situated in Japanese society to get cracking on the modernization, importing western technologies and implementing them as fast as possible.
Now, this process did basically tank the Japanese economy and piss everyone off. The conservatives took it out on foreigners, whom they began attacking in the streets. Meanwhile the other half of the country wants to modernize, and spend even more money they don’t have on guns and steam engines. One thing leads to another and soon enough the country is on the edge of civil war. This is really the critical moment in 19th century history for Japan. It could have ended in unending civil war for decades, but instead the war was luckily very short, and the modernizers were able to seize power, force out the old government, and “restore” emperor Meiji to full power. The Meiji government proved to be pretty capable and immediately set about reforming the government, taxation system, education system, military… practically everything. Because, again, they figured the only way to survive against the threat of invasion by a colonial power was to become a colonial power themselves.
So to that end they went to war with China, taking control of Korea and Taiwan, with they promptly plundered. That conquest brought them into conflict with Russia, and to the surprise of pretty much everyone at the time, they won, thanks to some actually very good tactics and use of modern technology and also the Russian empire being bad at everything in the 19th century. By this point the Europeans and the US couldn’t really ignore them so they said yeah sure Japan I guess you’re an empire too and they even got to technically be an ally in WW1 and come to the peace conference and everything, even while their government became even more militaristic and authoritarian at home