I have now been reprimanded a couple of times for answering a "bad question".
How am I to know when a question can be answered, so that I can avoid the embarrassment of being reprimanded for answering a "bad question"?
L.Dutch's answer is the correct answer, and I upvoted it
But I'm happy to give you some very specific advice.
Ignoring the Title of the question, if the question is three (3) sentences long or less, there's an 85% chance it's a bad question. If the post is only one (1) sentence long, it's a bad question — period. In fact, I question any post that's just one paragraph or so long (8+ paragraphs, give or take) that it's tedious to read it.
If the question posed in the title and the question posed in the body of the post are not, contextually, an exact match, it's a bad question.
According to the Help Center, Questions must be (a) specific and answerable, (b) include context, and (c) include restrictions/requirements. If a question doesn't meet all three of those expectations, it's a bad question.
According to the Help Center, Questions should include research. Yes, we're tolerant about this, but it's a huge red flag that obvious research (like the results of a 10-second Google search) were not considered before the question was asked.
Finally, in complete support of L.Dutch's answer, there are three Help Center pages you should simply have memorized.
and...
Every user should read those three pages regularly. They're the baseline. All other policies and issues brought up in Meta are in support of or clarification of those three pages. My perspective might be a bit ruthless, but if a question doesn't meet every expectation in those three pages, it's a bad question.
Let's start from our help center which clearly state
Answer well-asked questions
This should provide already some guidance on when a question is worth being answered, and you should be using your own judgment.
Moreover, at the time you posted your answer there were already two comments pointing out that that question had issues, in particular:
If despite all these red flags you still decide to write an answer and then see the question being closed, you have two options:
In both cases, bear the consequences of your action instead of complaining against other users.
The rule was broken by the opener, why say answerer breaks a rule ?
Many peer moderators put explanations for their closure votes as comments to the question. Answerers use that information already, before they start. I would say, just close the topic, when needed. Don't bother answerers with responsablities of openers.
Some question rules are incompatible with this proposal
There exist rules for questions, that will be incompatible with judging answers. An answer would be against the rules when there are too many other answers ? or when there is no clear single answer possible ? Why should an answerer be bothered with such issues..
Fishing for ideas.. but... can't the answerer decide if he/she wants to be fished ?
It often comes up. New rules seem to be introduced on WB to prevent "idea-fishing". I think I speak for many other answerers, please keep in mind WB questions are answered voluntarily, answerers give permission to use content, according to registration conditions on SE websites. I wonder if (peer-) mods should decide for answerers, it is wrong to answer, just because someone could "profit" from their answer..