If you walk into Walmart and intentionally walk out with a banana without paying, you can't get out of prosecution by claiming that you didn't know it was illegal to do that.
If, on the other hand, you accidentally neglect to scan the banana at the self checkout then it is a valid defense to say that you thought you'd already scanned it in and you must have gotten confused by all the other items you were handling.
Theft requires intent.