Do the crime, do the time. In other words you’ve been caught, take your punishment and be on your way (usually straight to jail).
In most cases this all too flippant phrase was trotted out when discussing low-level criminal acts and as almost every Scots child will know it was seized upon by harassed parents with warnings that if we misbehaved punishment would be swift and severe.
Don’t do it if you don’t want to be caught and punished, or words to that effect.