Is it considered rude to answer a question with a question? For instance: Q. Did you eat those cookies? A. Why? Would the correct response be "Yes I did (or no I did not), why do you ask?"
The context of the question is all important.
In your example, I suppose a direct yes or no answer would be most polite, unless the accused eater was the rightful owner of the cookies, and may possibly have more that they are willing to share.
Sometimes a question as an answer can be a polite commiseration.
e.g. Q: Why is this train so slow!? A: Why is the grass so green? Why is the sky so blue?
i.e. The answer here implies that the reason for the slowness of the train is unknown at this point, and worrying about it is not going to do any good.
Answering a question with a question needn't be considered rude, and is in fact used in linguistics and philosophy to better understand the subject matter at hand. By replying, "why do you ask", there can be a greater understanding between the two of you with an intent to better solve or dissolve the situation.