The web serial Worm (Parahumans) has an excellent take on this.
The unwritten rules. Heros have to limit property damage, and not go lethal unless absolutely required. Villains, in turn, don't go lethal on heros or civilians.
Both groups also respect each other's secret identities, unless they out themselves. Heros because villains can get nasty if backed into a corner too badly. Villains because going after a cape's family is a good way to get a kill order, and a heavy hitter involved.
In story there are also world ending threats. When one turns up, villains that are willing to help are out of bounds for retaliation. If they are willing to help, they are treated like any other cape.
End result, all the weird rules of heros and villains suddenly make logical sense. No-one wants to break the status quo.
It also leads to some funny encounters out of costume, or with new costumes.
