After rewatching both episodes, I didn't see any definite evidence that Hanzee knew ahead of time that they were going to the Motel. Between the cabin and the hotel we only see Hanzee four times.
- He enters the cabin and kills Dodd, spends some time there getting a "haircut", then flees when Lou and Hank show up.
- Next we see him return to the store, kill the owner, patch his wounds, and leave quickly in the stolen red sedan.
- We don't see him again until he is hidden on the roof of the Optometrist, spying on the troopers.
- He makes the phone call to Mrs. Gerhardt and lies, telling her that Kansas City has Dodd at the motel and they should come ambush them tonight.
The way I see it there are several likely explanations:
- He was already in town waiting for any sign of troopers, and happened to see them all pull in and park at the Motel.
- He followed them from somewhere near the cabin into town and got on the roof before they parked (this is somewhat thin because there's no way he would know they meant to stay there until they parked, but he was already on the roof when thethey arrived)
- Somehow he got word of their plans, over the radio or possibly he has been communicating with Kansas City and did some smart guessing that the police would attempt to wire Ed (also pretty thin)
- He overheard Ed mention to Dodd that he was going to give him over to Mike Milligan before he broke into the cabin, and guessed that they had a planned meeting place in town somewhere... (see number one)
I personally think that the most likely bet is number one, possibly combined with number four. It is also entirely possible that we will learn more information that answers this question with the final episode next week.