This is known as the ‘double jeopardy’ rule.
Enw hyn yw’r rheol ‘gwahardd cosbi ddwywaith’.