This might surprise you but the bible isn’t 100% accurate.
Jokes aside: scholars think that the Israelites were a group of Canaanites who lived as “outcasts” in the hinterlands and seized the cities after the bronze age collapse.
So Israelites came when the Canaanites collapsed but the causality is different than depicted in the bible. Also they weren’t that foreign in the first place.