Western imperialism, most notably Commodore Perry's opening of Japanese ports in 1853, forced Japan to confront the modern age. They knew that unfair treaties had been imposed by the West on the Chinese and that China's refusal to modernize made it vulnerable to European control. In response, the Japanese, led by the samurai, took a different strategy.
They set out on an ambitious and rapid modernization campaign. They imitated Western models of state organization, established a parliament, industrialized, built a modern transportation infrastructure, and updated and modernized their army and navy. At the same time, they maintained Japanese traditions, such as the institution of the Emperor, as well as the Buddhist and Shinto religious faiths.
The Japanese decided that to stay safe, they needed an empire like the Western powers. They saw this as a defensive move. They aggressively went to war against other countries in Asia, including Korea, Manchuria, and China, in order to secure themselves by becoming the dominant power in the region. Because they were strong and modern, they were able to dominate Asia until their defeat in World War II.