To put it short, Japan was scared.
Scared of what? Well, Japan was scared of going down the same way China did. A long time ago, Japan used to isolate itself. It refused to open its harbors to foreign countries, and so fell behind technology-wise.
A ship from the United States Navy arrived on the harbor of Japan. The Japanese told the ship to back off, but it kept going on. After the Japanese showed some aggression, the ship began shelling the nearby buildings. The captain of the ship forced the leader of Japan, the shogun, to sign a treaty with them to open its harbors.
This absolutely devastated the Japanese. The belief that they were strong was devastated by the United States Navy.
Japan had a giant reform in which power was given back to the emperor and industrialization began.
The country, knowing that it had to be as modern as possible, essentially copied actions of the West.
Unfortunately, one of these actions was imperialism. Japan had an incentive to conquer other nations, and they did exactly that until WW2 ended.
-T.B.