He is attacked at night on Weathertop.
He, meaning Gandalf, went to Weathertop because, in the Wild, between traveling from the Shire to Rivendell Weathertop is a great central point where you can survey they land around you and set out to continue your journey. It also helps that Gandalf and Aragorn had discussed meeting at Weathertop should things not go according to plan.
What doesn’t help is that the Black Riders were surrounding all areas around Bree. When Gandalf showed up around Weathertop, he lit a fire and naturally they were drawn to his light. Luckily, Gandalf was aware of the Black Riders’ presence and he was able to get away from the ambush.
Still, Frodo, Sam, Merry, Pippin, Strider, and Bill the Pony are traveling through the Wild, doing everything they can to pass undetected by the Black Riders. Even if they have to pass through the Midgewater Marshes.
Thank you for your time and remember, the crownless again shall be king.
– The Wandering One