It is for sure a philosophical debate.
But there is a difference between saying that someone did good, and that they are good. When you say that they are good, it implies that their moral stance is good.
In your example, if the person B did it out of loving to kill people for fun, and picked those victims randomly or to be able to use it as an excuse, is there any way to say that B is good? I don't think so. You can say or not that they did good, but not really that they are.
Followup on the spoiler
In the case of Dukat, he killed Winn out of purely selfish reasons, and couldn't care less about her being evil. If anything, he probably would have otherwise liked her. It's hard to count something as good, when Dukat had not even a gram of a sense of good when he killed her, and only did it for his personal benefit. He would have absolutely not have done differently (or on the contrary, would have enjoyed it more) if Winn was the most good and benevolent person in the universe.
If your definition of good and bad is purely based on results and not on intentions and morals, then maybe someone like Trump would retrospectively be considered a good person, because he would lead to insurrection and revolutions that would end up making the world better. With this logic, Hitler did a lot of good because now a lot of people hate fascism and nazis. For me, this cannot work, the results can only be considered good if the intentions were good. If you do something good out of bad intentions, then the result might be objectively good, but I won't count it as something good from you. That's where my definition of good and evil stands in this case.
Tl;dr: I don't count as good, something that is basically a side effect of bad intentions.