I have found a few cases when I try to answer someone's question based on my best understanding of what they are asking. Sometimes, I have made some assumptions based on their vague descriptions, or just based on speculation as to the source of the problem. Occasionally, these answers are based on wrong assumptions (shocking, I know). What I have found in some of these cases is that I get downvoted for these reasonable-yet-not-applicable answers. This has driven me to provide all my answers which are based on any kind of assumption as comments first. This works okay, but I've seen some discussion here on meta which seems to discourage posting answers as comments. So which is it?
Don't post speculative answers.
Posting answers as comments isn't what comments are for, if you aren't sure what the question is about, post a comment and ask for clarifications. There is a ton of unanswered questions you could be answering instead of trying to guess what the OP means and providing wrong answers when you fail to do so.
First off: there's no possible way you can do this "safely" if you're guessing. Accept that. If you can't live with the possibility of being wrong, follow Yannis's advice and stick to answering less ambiguous questions.
If you do want to gamble, I have some recommendations that can help to make this a bit less stressful for everyone involved:
Edit the question!
If there are two ways it could be understood, edit it to leave one. Explain what you're doing in the revision summary. Then leave a comment for the OP explaining what you've done and why, and advising him to roll it back and edit to clarify if you were wrong. This shows the author what he should have done originally, makes the question easier to find for future readers with the same problem, and helps to avoid issues caused by two answerers interpreting the same question in completely different ways and effectively answering two unrelated questions.
Be willing and ready to delete your answer
Like I said, it's a gamble. In spite of your best efforts, you might be completely wrong. Know when to fold 'em... And since we're listening to Kenny here,
Know when to walk away, know when to run
Ideally, the asker will take a hint from your edit and clarify his question. But sometimes, the lack of clarity indicates severe confusion, which he'll try to resolve by engaging you in a lengthy discussion in comments... Or worse yet, he'll keep changing his question each time you solve one problem to present another one. Unless you've nothing better to do than spend the rest of the day teaching him to program one-on-one, you'll need to extricate yourself from this situation. Even if you do have the time, you'll want to take it to chat.
You should request clarification from the poster in comments, and build an appropriate answer based on that feedback.
If the question so vague that it requires guesses on your part to answer, it's not a good question yet. Make the person who asks provide the required detail before you attempt to answer.
Note that this doesn't always work. If the person doing the asking doesn't provide sufficient details to make his question answerable, just walk away (possibly casting a close vote as you go).