Did the Israelites learn many languages in Egypt and pass them down (including to one of these two spies)? Is it known how Rahab was able to communicate?
Abraham, Isaac and Jacob lived in Canaan before the Hebrew people moved to Egypt.
Moses lived for forty years in Midian before he led the people into the desert.
During the wandering in the desert, the Hebrew people frequently fought the neighboring peoples.
All these interactions provided opportunities for some of the Hebrew people to learn Canaanite languages.