I have been in similar situations. I've also been asked to work on software that was unethical and illegal.
Thankfully those last two were over the top enough that I kind of began to develop a sense of my own responsibility.
Over the years and after getting some advice from some people I really respect my answer in all scenarios in all moments is this:
I am responsible.
I'm responsible for the code I write, the words out of my mouth, the thoughts in my head, showing up each day my job, and so on.
It doesn't matter what people ask of me, it doesn't matter what the circumstances are, or how I feel about it. I am responsible for my actions and choices.
Inevitably, this belief leads to a confrontation with people who believe that they own my choices. People who believe they can tell me to work all weekend after a full week. People who believe they can make me write poor, unethical, or illegal software.
I'm not saying that in these cases or moments I was right and they were wrong. Right and wrong are a distraction. We use that to justify what we're doing and why, but to me, the simple truth remains.
I am responsible. I'm responsible for my choices when they're right and I'm responsible for my choices when they're wrong.
This may make me sound very pig-headed, but this is how I operate internally. I'm curious about everything that is asked of me. I want to know everything before I make my choice.
Strangely, in all my years operating this way I've never been fired or demoted. I've been promoted in every job and am looked to for leadership even when my title doesn't command it.
I hear you, and I'm glad you've been able to take that position. But the question is less about what we should do (which may not be quite so black-and-white in every case) and more about understanding the reality of what does happen. For example, many developers must balance accountability for dev-related choices, large and small, with accountability for providing for their families. Not everyone can afford to die on every hill.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.