In general, biblical narrarives often anthromorphize God in ways that should not be taken literally. For example, when it says God walked in the Garden of Eden in Genesis 2, it doesn't mean that God has legs. In the case of Genesis 6, when it says that God "regretted" making man, it doesn't mean it literally. It's a literary device the author is using for the sake of the narrative. This is easy to explain.
The case of Balaam is not as obvious. This is one example of many places where there are clearly things going on under the surface that are not stated explicitly. First, remember that God had already told Balaam his intentions about the Israelites, and that Balaam should neither go with the men nor curse the Israelites. But then Balaam says he'll seek new counsel from God, at which point God tells him to go but warns him again not to curse the Israelites. So why is God angry when Balaam goes, when God explicitly permitted him to go and Balaam has not cursed the Israelites?
I think what's implied is that God was angry because of Balaam's intentions. Balaam wants to be able to do what Balac requests, and is hoping he will receieve some omen of approval. But God expressly tells Balaam not to go, nor curse the Israelites, explaining that he has bless them. Balaam, while being afraid to go directly against what God says, still hopes he might be able to change God's mind. So God is angry in part because Balaam is seeking to change God's plan for his own gain. This is alluded to in one of Balaam's prophesies.
>God is not a man, that he should lie, nor as the son of man, that he should be changed. Hath he said then, and will he not do? hath he spoken, and will he not fulfil? I was brought to bless, the blessing I am not able to hinder.
So God permits him to go, but not to curse the Israelites. And maybe God would not be angry except that he knows Balaam inwardly has evil intentions. Balaam still thinks he will change God's mind. So Balaam does multiple sets of sacrifices and each time God speaks through him saying the same thing. Balaam still will not go directly against God's explicit instructions, yet it seems that Balaam still was intent on cursing the Israelites. Balaam sees that the Israelites have favor with God, and God has praised the Israelites for not having any idols. So Balaam comes up with a plan. He advises the Moabites to tempt the Israelites with idols. Then, the Israelites will lose favor with God, and then Balaam will be allowed to curse Israel, or perhaps even it will be unnecessary and God will curse them himself. This plan isn't mentioned in the main narrative with Balaam, but it says later more or less that this is what Balaam did.
>Are not these they, that deceived the children of Israel by the counsel of Balaam, and made you transgress against the Lord by the sin of Phogor, for which also the people was punished? (31:16)
Note how it says that the deception was by Balaam's counsel.