A law is just a written contract between a group of people to act in a certain way. If it's not written down the accused use technicalities in their defense.
A law is a written contract kind of but it is applied to people who may not agree with it. Typically contracts are between consenting, signing parties.