In much of the ancient world gods were regional patrons of the local people. The writers of the OT make this clear, Yahweh was their god whereas Chemosh,, for example, determined the possession of land for the Ammonites and Moabites.
Do you not possess what aChemosh your god gives you to possess? So whatever the Yahweh our God has driven out before us, we will possess it.
The failure to bless the local patron deity with gifts and worship was understood to result in loss and hardship. Amazingly when peoples traveled to other lands they routinely gave gifts and prayers to the local deities to ensure passage and prosperity while in that land. The Egyptians even set up small shrines to local deities throughout Palestine which actually place the Egyptian Hathor in a subservient position to the local gods. The deities of the Levant were even honored back home in Egypt for the purpose of protecting Egyptian interests and family living there. Similarly, an industry of producing amulets or blessing totems for Yahweh for those passing through Israel/Judah existed as in many other places.