Are you asking how to write an adventure for personal use, or how to write an adventure for publishing? Because I think those are potentially quite different questions, and I can’t really speak to the latter.
This is all somewhat stream of consciousness, not in any specific order.
In terms of my own adventures, I prioritize worldbuilding, so I build a world first and then think about what kinds of adventures might fit within that world. Worldbuilding is its own conversation so I’ll focus on the adventure part.
I take an approach that’s somewhere between OSR-style play and narrative-style play. I usually have a handful of key “plot points” that I expect to happen in some form or another over the course of the adventure, but try to keep them as loose and modular as possible, and let player actions fill in all the blanks.
I don’t necessarily do “true” sandbox play- I mean I don’t disallow it, but usually I’ll create some framing device that gives the party multiple obvious leads to pursue and let them choose, and then later I’ll give them several more as events transpire. They certainly can do things outside those options, it’s more just about giving them a general direction. I also usually try to leave those options fairly open in themselves.
This might be something like, I’ll often use a “Handler”, who is kind of like an agent or manager, who relays information to the party for quests to follow. Other times, they might have some broad goal, and by exploring the location or speaking to NPCs, new leads emerge in themselves.
I think the key is just to keep things modular. Even if you have leads, or plot points, make them flexible, give players many options to get there, allow the players’ actions to affect those key moments. If you really want them to do some specific thing in some specific way, give them a good reason to do it.
If you build out some stuff and they don’t follow that lead, find ways to re-work your work to meet the needs of what they’re doing now, or contrive another way for them to wind up back there later.
I’ll also plant lots of seeds. Little plot hooks, details, events, that I may or may not have an idea of what to do with. If the players don’t care about a seed, I’ll abandon it and they’ll never remember. If they do respond well, or if I’m just dead-set on it, I’ll keep coming back to it, even if only briefly, so that when it does develop, it doesn’t seem like it just came out of nowhere. The end result will be a rich world, an intricate plot, one that seems full of intentionality, but actually you were mostly just making it up as you went.
When it comes to puzzles, traps, conflicts, etc., I generally don’t worry about having a solution. I’m not a great puzzle designer, and designing conflicts that are inherently interesting is difficult and I would argue not sustainable. Instead, leave it open-ended, make the details interesting rather than the task per se, and let the players come up with fun and interesting solutions that you never would have considered. They’ll have more fun for feeling like they “solved” it, it’s less work for you, and I would argue more fun for the GM as well, and meanwhile they think you’re brilliant. Likewise, I try to minimize actual combat, because almost always it ends up being not that fun and more effort than it’s worth on my part as a GM. Instead, I try to encourage non-combat actions to be used in exciting and “action-y” ways within a combat context, like having lots of environmental objects to interact with, or encouraging communication between the party and the opponents.