"Gress" comes from the Latin word "gressus", which means "step" or "walk".
The prefix "trans-" means "across" or "beyond".
So, "transgression" literally means "stepping across" or "going beyond" a boundary or limit. This is why we use the word to describe the act of violating a rule or law.