In a land where freedom is a memory, and justice is outlawed, the just must become outlaws
~ Tagline to "The Mask of Zorro"
Heroes who usually go against villains who are Lawful Evil (the ones who use the law for their own purposes and evil deeds). Sometimes may commit crimes such as murder, theft, terrorism, vandalism, etc. (Juvenile Delinquents and Outlaws count), but that still help save the day. There are several reasons why a good person would resort to crime.
Vigilante: The society/law system they live in is corrupt and oppressive and is making things extremely difficult for a good or neutral person to make a decent living, forcing heroes to resort to crime and/or vigilantism to survive and correct wrongdoing. This is the most common form of a heroic criminal and in some ways the rest of the examples fall under it. Examples include Zorro, Aladdin and Robin Hood
Minority Species/Culture: The hero is a member of a species or culture that is frowned upon and/or discriminated against by a majority species/culture, forcing them to resort to crime in order to survive since the local law enforcement probably is biased against their species or culture. Common in Science Fiction and Fantasy where multiple races can be found, and related to real life racism, the hero resorts to crime because the local law enforcement is more likely arrest them rather help them, simply because of their species or culture. Examples include the Dovahkiin if they are an Argonian or Khajiit or Esmeralda for being a gypsy
Being Framed: The hero is actually a decent law abiding person. Until they were framed for a major crime by a villainous character and are now a wanted criminal. This character is typically found in mystery stories where the hero tries to find out who really committed the crime so they can clear their name. But until then, they must resort to crime since law enforcement is more likely to try and arrest them then listen to them. Examples include Dr. Richard Kimble or Vash the Stampede
Tragic History: Sometimes the hero becomes a criminal because of their tragic backstory like being an orphan or being rejected by society so they had no choice but to become a criminal. Examples include Hiro Hamada, Megamind, Catwoman and Gru.