Japan closed themselves off from the world for most of their history
The US decided to send warships to deliver a letter demanding that japan open trading with them, Japan knew that the US was too powerful to fight so they agreed to sign treaties with the US. This lead to japan signing treaties with other nations as well.
Not all Japanese people were happy with the treaties but knew they could not do anything about it. After this came the Enlightened Rule, during this period of time Japanese officials modernized the nation, This turned them into an industrial nation. Japan became the leading producer of weapons and many more products, they also set up a modern army, and public education.