Ah yes, good old completely unexplained law system where the reader is supposed to guesstimate based of medival whatever the fuck they happen to know.
Clearly just beating the guards up or just not entering this random town through the front gate was not an option because, magic? Who knows.
Lets just do a random good deed and that will magically make any problems go away because the law is completely just whatever the guards feel like at the time.