People commit crimes; regardless of the level of technological development of the society they live in.
A member of a rainforest tribe murders another member; a US citizen murders another US citizen. Etc.
People steal, rape, assault, murder, destroy property, regardless of the level of technological development of the society they live in.
The objects and methods of the crimes vary, but the nature of the crimes is the same across history and geography.
And human societies have always tried to deal with crime and criminals somehow.
Either by excommunicating them, killing them, sending them to prison, etc.
So in a modern Western country, for example, a thief may have to pay a fine or is put to prison; a rainforest tribe may lash a thief. Either way, society has acknowledged that a crime was committed and punished the thief for the crime committed.
So when we read in old scriptures instructions for punishment, and we consider that this was intended for a society that didn't have the kind of judicial or penal facilities that modern Western countries usually do, it is reasonable to think that this was simply their way of dealing with criminals, and not something "religious."
Nevertheless, it has become religious law, that makes it religious. The whole problem with religion is that it fails to change with the times. Even when it's believers do change which parts of the bible they take seriously in modern times, when you get someone who really believes everything it says, that's dangerous. That's what fundamentalism is.