When I work on a D&D game, I start with a core idea for a world or story (for example, what if dragons were secretly playing a game for the fate of the world and no one knew). Then I build the world in excessive detail, including history, politics, organizations, and characters. When I write in an event (or when the players do) I want to know how it'll affect the world, and
for that I need to have the world ready in working detail. Once I'm satisfied with the expansive planning, I star play, adding more to the story and world on a session-by-session basis as the players explore and learn about what's going on.
At least, that's how I usually work on a D&D game. I've been slowly kicking out ideas for a campaign that I'm tentatively calling Starfall (after three or four rejected titles over the years), and I've been taking a different approach than I normally do. I may have mentioned it here before, earlier in the process. I've been building a framework of story in distinct arcs with specific themes around the core concept, adding and subtracting and re-organizing as I make progress.