I am currently writing a children’s novel while editing two YA novels. You might think I would have a hard time staying on topic, but I don’t. This is because I am writing three very different books. The children’s book is about a witch who has been turned into a pig, and she hasn’t had the time or inclination to turn herself back, and my other two protagonists are human women. The two YA books are also very different, as one is in the Steampunk genre set in the Victorian era and the other is a paranormal fantasy set in modern times. This means I can flip between all three without too much confusion.
However, sometimes I will start writing in one genre and find myself straying off topic. This is usually due to enthusiasm (I want to include everything I can), but it is a bad fault. What might make a conversation interesting – exploring tangential ideas – can muddy the clarity of your written prose. This isn’t a terrible problem if you are writing your first draft, but it can be a killer if you are writing an article to a brief.
If you are as bad as I am, it often helps to have a plan or a map, or at least an endpoint you are aiming for. There is discipline to writing, like anything else worthwhile.