First of all, the rat experience is not so relevant to a great extent to the question.
Animals can't reason (they can't have their own belief system and plan for the future).
However, there is some similarity with rats and humans. Rats are social creatures too. It could be that loneliness causes bad feelings and a distraction technique could be the drugs to which they got addicted.
That might explain why the rats got addicted to the drugs. For animals is all about stimuli, they don't have a belief system. I think that even if a social rat saw the drug and tried it once and a few more times it would get addicted. Same for people, drugs can be as part of a recreational/social activity.
Another comment, is that loneliness is basically the feeling of stress (because it is an inner feeling of unhappiness and a mix of anxiety, all which brings the person to rationalize that he is lonely). I would argue that since loneliness creates stress, to relief stress the individual turns to an avoidant stress coping strategy which is drugs consumption.
My account is one, there are more accounts of that relationship that other people add. But I struggle to bring any other relationships that will not be seen as being too much based correlation.
Also note that there are different mentality behind different psychology. Addiction of gambling is not the same as being addicted of drugs. In the former, the addict is addicted to win and in the latter the addict is addicted to the drug that kills the mental/physiological pain s/he has.