Breaking a law without knowing that the action being committed was an actual infraction of a law is referred to as "negligence per se." The person would still be liable for having committed the act that constituted a crime, but the fact that they did not intend to do so would act as a mitigating factor.
A common example of negligence per se is when a contractor builds a property that is later found to be in breach of building regulations. If there is any injury to a person while on the premises, the contractor would be held liable for the infraction even though they did not intend to hurt anyone, because their negligence resulted in the person being injured.