There are two levers.
First, there's education and comprehension, which help the individual to act in accordance with the expectations of the act and the code, the two instruments that apply.
Then there are the consequences, which can have a serious impact on people's behaviour. I will give a very simple example. If the police give a ticket to someone crossing the street when the light is red, it will have a deterrent effect on the people who witness it.
So there's prevention that can be achieved through education, but there is also punishment, which should be applied occasionally to make sure everyone understands that a given behaviour is not acceptable.