Ammon and Moab were cousins, the fruit of Lot by way of incestuous relationships with his daughters. That occurred at the end of Genesis 19, preceded by and tightly connected to the perversion and cruelty of Sodom and Gomorrah. That incestuous relationship was the beginning of two of the most godless peoples ever to dwell on this earth. When the Lord now hands Israel into the hands of Moab and Ammon, it appears he is identifying them and their sinfulness with that antecedent wicked culture.
13 He gathered to himself the Ammonites and the Amalekites, and went and defeated Israel. And they took possession of the city of palms.