Here in my country, the inmates who have a lot of money and power inside the prisons are wealthy people who were imprisoned. How do they keep money out of prison? They continue to have lawyers from reputable firms who can influence the entire prison management system. They manage to please the prison warden so that he treats the wealthy inmate well, allows the wealthy inmate to gamble inside the prison, and leads his criminal group inside the prison. In exchange, the prison warden gets a good life with his family.
When poor people in my country enter prison, they become employees of the wealthy inmates. So, they don't have money to gamble. At most, if they do have money, they use it to buy cheaper phones to continue communicating with the outside world.
Our country is in the same situation. The only difference is that the big-time drug lords are the ones ruling inside the prison. Even the Secretary of the Department of Justice couldn't escape the controversy because he was implicated as one of the protectors of the drug lords and was even imprisoned for six years when the new president, who wasn't his ally, took office. In prison, those with a lot of money truly reign because, just like in your country, the prison officials can be bought.