I'd argue that the elephant in the room is, that this problem is more about the practical feasibility than it is about the theoretical moral responsibility.
Like sure there is ideology, the focus on individual liberties has found it's way into eurocentric legal systems. Ethics has largely moved away from consequentialist and utilitarian ethics which put the focus on the effect of an action and more towards a value ethics that treats the individual as an almost autonomous agent that possesses the free will to do or not to do as they see and merged the teaching of values with some deonthologist "you shall" demands of the law respective law makers. Now ideally constitution writers would love that the values and spirits of the law be the guiding principle of ethical actions, while often enough the letter of the penal code is what people end up negotiating over in various institutions in attempts to circumvent the spirit without ending up on the wrong side of the law.
So the relevant question is no longer whether an action is bad, but what should the individual have done differently and were they reasonably able to realize the wrongness of their deed and do something better in the first place. And in that regard every individual is considered individually. Any court case has just 1 accused per case and their specific background is scanned individually.
That's the theory, in practice legal systems might still opt to create boiler plates of precedents and treat individual cases as instances of a class of lawsuits. And I'd argue that has more to do with practical legal concerns of a lack of resources and willingness to deal with similar cases individually in an attempt to speed up the trials, than it has to do with moral principles.
The things is, as important as it is to get to the right decision in a case, doing it speedy kinda also matters, because if a court case takes longer than a lifetime than either you're detained and thus sentenced to prison before you even got a verdict or whether you will eventually be punished is a matter of your religious believe in an afterlife.
Now obviously this has nothing to do with the subject of moral responsibility, but without a reasonable amount of swiftness in decision making you'd make a mockery of your legal system. So you have factors in the legal system that are not directly motivated by moral concerns yet which nonetheless are crucial even with regards to moral our immoral outcomes.
And that is just the regular legal system where major crimes like homicides happen at a rate of <100 per 100,000 people in high crime regions, <10 on average and in many countries even at or below 1 case per 100,000 people. So where there is plenty of time and resources to investigate thoroughly and individually.
And where the majority of crimes are rule breaking to gain an individual benefit or emotional conflicts where victim and perpetrator know each other. So there is a good chance that in a lot of cases such an individual approach actually works and that the cases that are different are scarce enough to allow for a more fine grained investigation. Idk organized crime, terrorism, political conflict where the solution likely isn't in the penal code to begin with or where the question of guilt is not even relevant or in doubt.
So are we doing the things we do because we believe it is moral or are we just doing them the way we do because that's easy to facilitate and rationalize in hindsight why that is just... I mean it's supposed to be otherwise we might have riots and extrajudicial "justice", so the morality might follow after the facts and not drive it.
However there are cases, where such an approach reaches it's limits. Like if we go a step below organized crime we might find something like bullying. Where the individual guilt of the participants, might be low on the crime scale and where an awareness of guilt might even be lacking as the victim has a different framing of the situation than the people around them, but where collective damage done by the whole of the participants is nonetheless massive and can lead to suicide or murder of the victim or of perpetrators and bystanders.
So the individualist approach to guilt has a problem, should they punish based on guilt which might be low or worse hard to assess in the first place, where in dubio pro reo (when in doubt for the accused) would result in low punishment and as such a marginalization of a serious the crime or should the punishment be high and sweeping where you basically violate a lot of legal and moral principles?
... And now consider all that in the context of war. Where on the one hand your entire (legal) infrastructure might either have collapsed, been stripped down to martial law and emergency measures, where the availability of legal protection and revision might be a matter of where you live, whether that comes with person danger and risk of harm for getting to another place, where in the absence of a law, law enforcement might "become the law" as they are able to deal out harm in the name of the monopoly of violence while you can't immediately resist and can't count on getting to a higher level in time or at all to complain and can't be sure that the cop wasn't actually authorized to "re-establish order by all means necessary".
Also I'm not sure how much the Nazis are a regular or edge case. Like the fact that they were the aggressors for a large part of the war probably helped to not disturb the legal infrastructure too much... Apart from the obvious elephant in the room that they turned it into a sham. Also the fact that the highest level thought that their actions were justified meant that there might have been a lot less secrecy compared to when they were thinking of a committing a crime. So there's a lot of paper trail and documentation by the perpetrators themselves who orderly kept book and weren't able to destroy that in time.
Not sure investigators are always that lucky when it comes to recreating the situations of war crimes and crimes against humanity. Just puzzling together how many people died, where, who was in the vicinity at that time and so on could all already be difficult when everything is in ruins and loads of people are dead. And that's just the brute evidence of the deed and whether people were involved in them. That's not making specific claims about the involvement, their motivation, their commitment or aversion to them, etc... which might only be possible in isolated case or downright impossible at all (or far outside any reasonable time frame).
And the other thing is that a lot of the crimes are likely not just motivated by individual rule breaking for personal benefit or relationships (love, friendship, kinship or whatnot) gone wrong, but the general vibe of a situation, which is a collective product of many factors might have contributed substantially to those deeds.
Like if you arm people, tell them scary stories about an enemy out to get them, send them into a foreign land and let the fear breed in them, then it's very possible someone will snap and shoot at something or someone that moves out of mortal fear. Likewise if armed invaders come to your country and you've been fed scary stories about them, it's very possible that you see them as a threat and at least fire warning shots. And once the shooting commenced each side will be able to claim the moral high ground of just defending their bare lives and the lives of the people around them.
So yeah it is possible that a soldier fighting an unjust war believes that he's fighting a just war. It's also possible that they fight an unjust war, know about it, but think it's to their benefit. Maybe they are overwhelmed by fear and hatred spread and bred by propaganda both from atop and from their peers or maybe they actually were always inclined to brutality and now have a legal valve for it. What used to be penalized is now glorified and praised. Maybe they are forced to believe lies or maybe they want to believe they aren't lies.
Or their superiors. Did they tell them to commit war crimes? Did they give them objectives that were impossible without committing war crimes ("enhanced interrogation", "clear sector")? Did they tell them lies about their targets and they only later realized their crimes? Did they leave crimes unpunished thus promoting them? Where they unable to punish crimes?
Or the politicians, did they spread conspiracy theories to instigate a war? Where the conspiracy theories already in the population and they chose not to dispel but use them? Was the population driving politics and deliberately elected people who genuinely believe the conspiracy theories?
Like there are so many possible scenarios of motivations and circumstances for individual actors that it's often only possible to get the ones at the top who were nominally responsible for their institutions whether they actually were instrumental or just decorative as well as those who literally have blood on their hands so that physical evidence can be compiled.
While the guilt of the rest is much harder to assess, yet nonetheless very significant. Also they might be somewhat ambiguous as well. Like how would you rank a journalist reporting on war crimes of the enemy? Are they spreading hatred and assisting the propaganda, dehumanizing the enemy and give rise to war crimes of that side as well or assuming they truly happened would it be immoral to the victims and the potential victims to keep silent, would it enable the perpetrators and cause more harm?
Also you could have monsters that grow into their role over time. Like picture a soldier just doing their job, they killed someone, but through little fault of their own, no reasonable attribution of individual guilt, pure self-defense no legal paper trail. They nonetheless have to justify before themselves that they killed someone, so what previously had been just "the law" which they followed because "why not, sounds reasonable", might now take on the role of a more fundamental, religious dogma, as if the law is wrong -> I am wrong and hence they might follow these rules much closer and with more conviction than they had done before, but would an outsider be able to see that change?
Or people have the tendency to see themselves as morally superior to the average, so if they done something wrong they might come up with all sorts of mental contortions to justify before themselves why their deeds were ultimately benevolent or less malevolent than they look like. And that could be malevolence but it could also be a self-defense mechanism. Or they could embrace the idea of being a monster of lacking free will and being insane to escape the realization of what they deliberately done.
Or how groups itself might foster or enhance criminal behavior. Like if soldiers around you are all the non-hostile human beings in your vicinity than you are naturally drawn to them and accept them as good and it takes a lot more than normal to see their bad deeds for what they are and distance yourself. They are currently your peers and the moral standard of "society" (which has become a lot smaller). So as the most extreme are no longer criminalized and outcast their behavior gets normalized.
Or how groups might push their members into acquiring guilt. Like hazing. By doing stuff you wouldn't want to talk about to outsiders you prevent people from talking to outsiders, because the one's you could talk about have dirt on you as well. Which in the worst case could become a race to the bottom, where a competition of violence and immoral behavior emerges where the winner is given acceptance and praise by the group, while the group receives the benefit of being able to point to someone else as "they are much worse than me". When in reality that behavior might actually be much more sinister than the quest for acceptance by adhering to social standards set and normalized by other people.
Now I'm pretty sure many people will agree that there are a lot of those dynamics and situations where you can't expect that level of analysis from an individual in distress, under sleep deprivation, potentially on drugs and in constant fear of their lives. But how would you tackle that practically. Who's actually experiencing that and who's just using that as a cover? Who is making others believe that they are a bully to not be the victim and who has a hedonistic pleasure in being a bully?
Those are very important questions but often enough you can't practically answer them and so despite people having an intuitive understanding that the victim who fights back isn't the one that should be punished the most, actually modifying the legal system to acknowledge that and to do so in a way that is universal and not just anecdotal is a lot of work.
Also often enough you'd not actually do that in the legal theories, but that would be dealt with on a societal, social and political level trying to understand and prevent by anecdotes and to account for that, rather than to deal with it by assigning responsibility and in extension punishment where you'd struggle to ever find the necessary level of evidence for the claim.