This contradiction is typically cited in the scholarly literature, although for my part it doesn’t seem all too problematic, nor even relevant. It does create for some interesting narrative tension however.
Scholars who note this contradiction usually argue that the story about Balaam and his talking ass come from a different tradition. In either case, Yahweh’s pronouncement that Balaam should go with the king’s men in Num 22:20 and Yahweh’s anger that Balaam is going with these messengers in Num 22:22 are in stark opposition to one another. Whether this is an inherent tension intended in the story itself or the product of competing traditions, I’ll let the reader decide.