By what logic were Israel's 1967 occupations legal?

So even ignoring things like the Palestinian areas occupied by Egypt and Jordan weren't their's to lose, and to my knowledge you couldn't conquer other countries, even if the war started as defensive, but Israel itself started the war.

There was an Egyptian sea blockade and the neighbouring countries were giving hostile vibes and possibly interested in starting a war, but the war definitely started with Israeli airstrikes to the neighbouring countries.

I'm from Finland and it reminds me a lot about the continuation war. Germany had few days earlier started operation Barbarossa and in Finland there were plenty of German troops and the Finnish army was in full readiness. Then Soviet Union did airstrikes into Finland. I've never heard anyone say anything apart from Soviet Union starting that war (which I agree with), but their grounds for airstrikes were at least as strong as Israel's in 1967.

By what logic were Israel's 1967 occupations legal?
Post Opinion