Ok, I've experienced the exact same thing as you do, abd123, so I can totally identify with your frustration over having your work classified as irrelevant or ' not answering the prompt.' This is because I normally tend to overdo things, and luckily, I managed to pull it all together a few weeks before my final exam. This is the precise advice my tutor gave me:
She told me to read the prompt carefully, but never to overthink it. You would also need to do a 5 minutes plan in the exam just to get your thoughts together. Now this is probably the most important piece of advice she gave, and that is to engage the ' keywords (synonyms)' of the prompt into your topic sentences. Make sure that you finish off your paragraph with a clear, strong sentence that ties back to the contention of your paragraph/topic sentence.
And if you keep getting out of topic, perhaps you should take more time to write, give yourself two to even 3 hours to write a piece if that means you won't get out of topic. Always think before you put your thoughts onto the paper, think about how the sentence ' would engage/answer the prompt' and you will slowly improve over time. Like I have stated above, make sure that you always engage the keywords of the prompt into your topic sentences, and at the rest of your essay as well if you can.
Cheers mate,
Best of Luck