You are correct to say gambling makes it way into nearly all environment, including prison wards. It is not necessarily about money but about the need for distraction, connection socially, and a sense of control in such a place where freedom is restricted. The negative aspect is just like you said: going into debts and even misunderstanding may result to violence quickly. Therefore while it is occupying an empty space, it equally brings risk. This shows that gambling is not just all about gains, rather it's involves the human personality desiring play, risk and also escape, as well as in the most difficult situations
Gambling in prison is not 100% for distraction, it is another means prisoners use to get some basic items they need in the prison. They don't work to earn money, so it is only through gambling they get what they want.
One of my major concern about these gamblers Gambling is that it builds another form of character in them. I see prison as a correctional facility where prisoners form good habits over time while regretting some of the actions that has led to them being deprived their freedom. A Prisoner who eventually gets addicted is getting himself into another mess when he lives prison.
It's always been like this, prison is supposed to be rehabilitative but in reality it makes a person even angrier who will cause more trouble when he gets out, fortunately I've never been in prison so I can't know how they spend their time, but I think that playing and betting is the thing that passes the time the most and gives you adrenaline, so I think that's the reason why they play