Yes you are right, we should avoid transactions between friends, because it can be something that will damage the good relationship between us. Even in urgent situations and it is not for gambling, if there is something that can be done other than borrowing, then it is better to do something else first.
I once heard something on social media, if they are hungry then come, I will give them anything to eat, even when I don't give it then it is better to be hungry together, but never borrow money.
As the saying goes, A man is known by the company he keeps, I think it is better to not lend money to friends who borrow money from us for gambling, even if they do not remain friends.
Because at some point, it may happen that seeing them repeatedly gambling with this loan, I mean, their addiction may also lead to our addiction, which is very scary. So I think that without those friends, nothing will happen. But we will definitely try to support our friends in the right emergency situation, whether financially or mentally.