I don't know how strict the gun laws are in Thailand, but what I do know is that Thais see laws as something to ignore. Unless gun laws are an outlier in regards to compliance I wouldn't take much notice of them.
That the gun was illegal in someway seems a possibility, but i could also have belonged to someone else, such as a relative. What are the rules, if any, regarding weapons storage? If there are were they in place. If the gun did belong to a relative, and there are regulations around safe storage then that might well be a weak point.