Campaign planning/world building - eviltoast

Hey guys! I’m a newer dm (not a new player, been playing for a few years) and I just want to ask what a dm should consider when it comes to planning and worldbuilding. I would also like to ask if you have any tips for when a player goes wildly off course in a direction you have zero ideas for. You guys got tips?