That's a fair point certainly.
But looking at Axis for example... the heroes as a group collectively agreed to try the spell plan because frankly they had nothing else. And it did work in the sense that it sucessfully stopped Red Onslaught. But if the Avengers and X-Men are all arrested and imprisoned for their actions hypothetically speaking at least until a trial, what happens when an incursion starts or Galactus shows up in New York. Where does the greater responsibilty lie? In following proper due process, or in essentially doing their job and keeping the world safe?
I think that's the other aspect of heroes often having the government and law look the other way when they can. Everyone knows that the world keeps spinnng because these people are out there ensuring that it does. That doesn't necessarily give them a free pass to do whatever they want... if they're intentionally killing people of their own free will, that's crossing a line I don't think government or the law will look away from. But if like in Axis they went along with a desperate plan which did likely save the earth but resulted in a good deal of collateral damange, I think government and law will go easy on them... because like it or not they are needed and a greater good is served by them not sitting in a jail cell.
There's a balancing act that needs to take place. It's not entirely fair... but it is necessary.