אמר רבה בר רב הונא אמר רב הונא ואמרי לה אמר רב הונא א"ר אלעזר מן התורה ומן הנביאים ומן הכתובים בדרך שאדם רוצה לילך בה מוליכין אותו מן התורה דכתיב לא תלך עמהם וכתיב קום לך אתם
The gemara learns b'derech she'adam rotzeh leilech molichin oso from the fact that Hashem first told Bilam not to go with Balak's messengers, but then in the end he did allow him to go.
Yet that's not where Rashi on our parsha quotes the limud from. It's only later in the parsha, after Bilam's donkey is stopped by the malach and Bilam offers to turn back and is told that he doesn't have to that Rashi comments (22:35) לך עם האנשים – בדרך שאדם רוצה לילך מוליכין אותו
Why does Rashi change the context of the limud from that of the gemara?
R' Baruch Mordechai Ezrachi in his mussar shiurim writes that the gemara and Rashi are addressing two different points. The gemara is speaking k'lapei shemaya and telling us that a person's ratzon can somehow change things upstairs.
Rashi is speaking about what's in a person's heart. You might have thought that once Bilam had been told by Hashem that he would not be able to say what he wanted, that he might have reconsidered what he was doing. Kah mashma lan Rashi, or I should say kah mashma lan the malach, that Bilam was still a rotzeh as much as before! So long as there is still a "rotzeh," there is still "...molichin oso" and therefore no need to turn back.
Bilam's response to the malacha, "חָטָ֔אתִי כִּ֚י לֹ֣א יָדַ֔עְתִּי כִּ֥י אַתָּ֛ה נִצָּ֥ב לִקְרָאתִ֖י בַּדָּ֑רֶךְ," is strange -- if indeed he was unaware of the malach, לֹ֣א יָדַ֔עְתִּי, then why is it חָטָ֔אתִי, that he is guilty of any wrongdoing?
Sometimes being unaware is itself a crime. Ha'levai that Hashem should send us a malach to stop us when we are going to do something wrong. Here Bilam is zoche to something special, yet he is so caught up in what he wants to do that he is oblivious misses all the signs and marches onward. (See Meshech Chochma on why there was this miracle of the donkey speaking.)