The progressive form (-ing, which you've called the gerund here) is used with the auxiliary (helping) verb 'be', not do. I don't think you ever get the progressive form on it's own, nor with any other auxiliary including 'do' here. This is why B is incorrect, it doesn't have the auxiliary 'be'.
Also, for A (and B), you need to switch around the order of words, since it is a question, thus: "Why does it not work?".
If B read, "Why is it not working?" or "Why isn't it working?" then it would be correct.
Just as a question, is there such a thing as 'does not + progressive'? (or 'does not + gerund; for that matter)