For hypothetical example; Father/son duo are criminals, harming, killing, and stealing innocent civilians. Superhero fights them, resulting in the father dying. Son is now portrayed as a sympathetic villain because all he wants is to avenge his father… despite all the fathers of children they murdered whilst comitting crimes.
Side question; do you feel sympathy for the villains portrayed like this?
It might be done for a variety of reasons.
You can give the character more depth, humanize yhem, or make them a more relatable by showing how they deal with loss.
You can show the villian losing their last shred of humanity or sanity and raise the stakes. The villian’s goal may shift from robbing banks to destroying the city.
You have a reason for the villian to attack the hero directly instead of fighting the hero when he shows up to ruin the villian’s plan