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.
I think most of us have been in position #4.
The main thing that I'm trying to do when in that position is to explain as much as possible all the counter-arguments, in the simplest way possible.
However, there are cases in which it's normal to understand why you need to cut corners, especially if you're trying to build an MVP.
That being said, since I'm always trying to do my due diligence on explaining all the possible outcomes, if everything comes falling down, I don't feel accountable at all, nor do I make my co-workers feel accountable in relation to the project/client if all the red flags were rose beforehand.
Oh Ya. Sometimes you have to choose your battles. I'll always speak my mind, but at the end of the day if I'm asked to build something that is ethical yet doesn't make sense for the business or for the users - after expressing my mind - then I'll kind have to weight out whether it's worth fighting for or not.
I've found, in those environments where this tends to happened a lot, it's usually a lost cause.
For me, the key is to make sure I speak my mind - which I always do. And as you mentioned, this many times will lead to looking for a new job.
So - Yes.
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.