Diverting thoughts of wanting to gamble by doing something else is one thing that can be done to avoid the habit of gambling, but this is not easy because for people who cannot control themselves they will still follow their desire to gamble and for those who are addicted no matter how difficult the situation is they will follow their desire to gamble.
Diverting your thoughts to something different from gambling is not a permanent solution but only a short term solution that you might not be capable of doing someday when the desperate to gamble increase more. What you should be capable of doing is to not gamble at all regardless of not doing anything else. Learn to say no to gambling and train your body to not allow it get to a stage that when ever you see gambling activities going on, you want to participate too. Prevention of addiction can be done by controlling how you gamble for people that are already into gambling. Controlling your gambling schedules will help reduce how long you gamble and how much that you are losing and this can help prevent gambling addiction too.
Maybe this will work gradually, for example a gambler who is addicted and wants to recover from his addiction then maybe he should be able to fight his urge to gamble by diverting his urge to gamble to something else and if he can be consistent in doing it maybe in the future he will be able to not gamble at all because his urge to gamble has faded because the diversion he did was successful. Also no matter how severe the addiction is, it can definitely be overcome if the main perpetrator has the goal of becoming better but if not, there is no need to hope too much. Apart from that, gambling addiction will not occur if they have a good view of gambling, but when they view gambling wrongly, an addiction is a risk that will definitely occur.
Remember is always very easy to say than done, though you opinion is a valid one. you know when you're not a gambling addict of course everything seems to be very easy for us to overcome, while those who are addicted is really going through a lot deep down which is why they don't always think straight even if they try to find a way out. definitely they will still find it very hard to Stick to those things that can help them to minimize the addicted.