If one understands the dangers of gambling addiction and must stay away from it then the only way is to never try to get into gambling because anyone who has entered into gambling has the potential to become a gambling addict.
So far, there are lots of gambling addicts who are difficult to cure unless there is intention and self-will to recover, so one can further limit the gambling activities that he has done.
Yes, when an addict has to deal with the law and ends up in prison they have the opportunity to recover until they stop gambling, which was always done before, but sometimes after they are free, there will be another desire that will appear to gamble again, and this is something that is hard to avoid.
Especially if they live in an environment full of freedom and an environment where there are lots of gambling activities, it is still possible for them to return to how they used to be where they liked gambling.
A gambling addict who has been affected for a long time will be difficult to cure. He also will not be able to see that he has a gambling addiction because he only knows how to gamble and does not know how to stop. Only other people could see him make the mistake of gambling non-stop.
If gambling addicts have to deal with the law and end up in prison, they must be developed to cure their gambling addiction so that they will not return to gambling when they get out of prison. This also requires help from his family, where with increased support from the family can give more confidence to the gambling addict. He will also think about getting well soon and not wanting to repeat his mistake.
When people become addicted to gambling they do not realize their addiction. Many people know about addiction but cannot control it. Moreover, if one cannot control the addiction by himself, it is difficult for others to protect him from that addiction. Also, I don't think that jail is very useful in saving a person from gambling addiction. If the gambler can't give up by his own self, the gambler is likely to become addicted to gambling once he is released from prison. But naturally, when a gambler abstains from gambling for a long time, he learns to control him self.
A gambling addict can only ask for help from other people to help him get out of gambling. Unfortunately, many gambling addicts do not realize they are experiencing gambling addiction. Only other people can see his gambling addiction. If other people also don't care about him, he will have no hope of recovery unless there is a desire from him who has been awakened to the dangers of gambling. The punishment given to a gambling addict can only prevent him from gambling for a while but if the addict is not helped to recover, he will return to gambling again. It will continue to repeat itself without stopping and maybe the government needs to help by setting up a rehabilitation center for addicts.