Gambling can also be a viable option for those who are depressed already. It can function like alcohol. It is not always the other way around, it is not that you first gamble and then get depressed. You can be depressed but see an exit in gambling because it makes you forget your problems for a second. Sadly though it is mostly causing more problems afterwards as you are most likely not fully in control of your mind if you are depressed and therefore feel like gambling.
An interesting point of view and I would add to it - a person who has gone from problems (from real life) to gambling does not necessarily become addicted. Some begin to study mathematics and algorithms in depth (to try to surpass the casino), someone analysts (to surpass bookmakers), in principle, this is an excellent self-development and can be a good impetus to become successful in a new field for themselves.