Whenever I get an idea and trying to write it, my thoughts/plot goes all over the place. When I start writing it out, I find myself veering off into a whole different direction than I intended to. What can one do in this scenario?
I guess first I’d say that sometimes veering off in a different direction isn’t such a bad thing. Maybe it means that once you start writing, your creative intuition is seeing new and exciting ways the story can go. It can be fun to explore different avenues and see where you can go with a story before settling on one definite storyline. What you originally imagined for the plot might not actually be the best approach! (I find it rarely is for me.)
But if it bothers you not to know how the story’s going to go before you sit down to write, I recommend outlining. That’s what I do before I start any of my books. I write a lot of notes brainstorming what might happen, until I’m pretty sure I’ve figured out the best and most interesting story that could develop from the premise and characters. And then I write out, point form, very sketchily, what’s going to happen step by step, in the approximate order it’ll appear in the story. That gives me a good guideline to follow when I start actually writing, and it makes it much easier to get through the first draft without writing myself into a corner I can’t get out of.
Even if you outline, though, I don’t think you should ever get too stuck on following that outline. New ideas always occur to me when I’m in the middle of writing the story, and often better ones than I had before, so I’m always ready to adjust my outline to make the story stronger as I go, even if it means taking it in a direction I hadn’t considered.