Despite all we are told in chapters 22-25 and the sins of the people therein, we discover in other readings that Balaam was an instrument of the Devil (Joshua 13:22; 2 Peter 2:15; Jude 1:11; Revelation 2:14).
Balak, king of Moab, and his people are frightened because they have heard of the victories that God has given to His people the Israelites. They realize that they are not able physically to defeat these people, so they use subterfuge. They hire a witch doctor to put a curse on them, but one who has some familiarity with God/Yahweh/I AM.
I find it typical of the human condition that when Balaam’s donkey tried to save his life (22:22-27) that he became so angry when the donkey spoke to him (22:28) that he didn’t realize the obvious and argued with the donkey!
Balak should have caught on when he yelled at Balaam for “actually blessing them.” “I paid you to curse” (23:11), but he kept pushing for his money’s worth (23:13, 27).
In Psalm 35 David asks God to “get” his enemies. And David says that he will rejoice, but he will rejoice not in God’s punishment of his enemies (which is a sin), but he will rejoice “in His salvation.”