For the most part, the criminal justice system doesn't just punish criminal acts -- a defendant must also have the intent to commit a crime to be found guilty. In legalese, this is known as mens rea, Latin for a guilty mind.
There are a couple exceptions to the rule, and different crimes can have different intent requirements. Here is how mens rea comes into play with criminal prosecutions:
Intent, not Accidents
Generally, we don't to send people to jail for mistakes. Criminal liability is based on both an illegal act -- say picking up someone else's wallet -- and the intent to commit an illegal act -- the knowledge that the wallet wasn't yours and the intent to take it. An accident -- mistaking the wallet for your own -- is normally not a crime.
A defendant's mental state can take many forms, and different statutes can have different levels of mental culpability:
The greater level of intent usually corresponds to more serious crimes and more serious punishments.
There are some important exceptions to the mens rea requirement. These are known as strict liability crimes and can be prosecuted regardless of what the defendant knew or intended. Normally these are more serious crimes like statutory rape and sexual assault. In these cases, it doesn't matter if the defendant believed the victim was old enough to consent to sex.
Additionally, many traffic crimes are strict liability offenses. For instance, you can be guilty of speeding even if you didn't intend to speed or know you were speeding.
If you've been charged with a crime you didn't intend to commit, you should contact an experienced criminal attorney near you.