"Legally" is such a strong word.
"In practice until somebody big and bold enough comes along, and the world sits on its thumbs until then" is the more normal rule.
Examples abound of one country occupying and perceiving that it owns, for all practical purposes or outright, some other territory. A few examples with varying degrees of merit follow. Some of these occupations still exist. Some have been redressed. In each case force majeur - military or political, by 3rd parties is usually the dominant factor in the occupation being undone.
Some references have been included - but these cases are so well known and easily searched for as to not worth having more than token links provided - and the chances of many considering these largely shameful examples worth spending times on seems small.
Israel beyond its originally established borders.
Or beyond the 1968 borders.
And/or "The West Bank".
Or ... .
The Soviet Union / Russia foray into the Baltic states, where they'd be still if things had worked out differently, and may yet again be if ... .
Germany and Stalin's-domain combined dividing up and "destruction" of Poland.
Hitler: Poland will never exist again (non verbatim).
Indonesia into "West Papua / Irian Jaya - to this day.
This is a classic example of a "legal" takeover of another "country" by means which make sense only to those who implement them and their supporters.
This was a Dutch 'colony" transferred to Indonesia's "care" post WW2. They have no moral right to be there, but the international community has abdicated their responsibilities. The Indonesians certainly do not expect to leave.
Indonesia into East Timor.
East Timor has achieved a sorrowful, bloody and unsatisfactory "freedom".
But the example is still a good one.
The illegality of the occupation is reflected in the current freedom - achieved at the cost of a vast number of lives.
China into Tibet. & China into Xinjiang.
China has more established historical precedent to occupy Korea than either of the above.
WHAT IS CHINA’S ARGUMENT ON TIBET?
[Tibetan Sovereignty Debate - Wikipedia
India & Pakistan into Kashmir.
On the division of India into India and Pakistan Kashmir exercised its legal right under the rules at the time to be an independent state. What followed is history. India and Pakistan have argued and fought ever since over who is legally entitled to "own" Kashmir, when by the rules of engagement it should have remained independent. [One can make a fair case for the view that had it done so, while there would have been ongoing repercussions, they would not have been anywhere as severe as they have been ever since. An independent Kashmir is still suggested by some as the best solution to the 70+ year old problem.
Serbia into Kosovo. Kosovo claimed the right to independence, which not at all surprisingly was contested by its "masters". Long ago (1200 ish) the Knights of Kosovo were the masters and this fact is not forgotten to this day by any of the parties concerned.
The annexation of Goa by India.
The annexation of The Crimea by Russia.