Merriam-Webster provides this sense of the word in its definition of rat:
4 : a person who spends much time in a specified place
// a mall rat
Interestingly, Oxford Dictionaries indicates this sense is specifically North American—and it provides many more examples of other words that it's used with.
In the following, the emphasis is mine.
‘After spending a long, hard winter as a gym rat shut-in, you're probably hot to trot outdoors.’
‘I'm a 46-year-old Ohio river rat who's gone there half a dozen times to mountain bike and ski.’
‘Rhyming, however, is the favourite sound effect of slang, as in boob tube television, frat rat member of a US college fraternity.’
‘Shouldn't we at least insist she sells some records like, this decade, before she gets any more coverage for her sex romp/love rat lifestyle?’
‘Peralta ripping in back of Mar Vista Elementary School - the first playground he was officially kicked out of as a young skate rat.’
‘Then or course there's the biggest closet rat of all, me.’
‘And the bag boys all seem to be happy, happy surf rats, with funny haircuts and pretty smiles.’
‘That bum sitting on a heating grate, smelling like a wharf rat?’
‘Mali, while seeming sophisticated, wanders in and out of ghetto rat behavior, especially when it comes to her man, Tad Honeywell.’
‘Some eighteen year old street rat from Paris, France… I wanted him so badly in my world of glitz and glamour… what am I saying?’
As to why the word came to be associated with frequenting a locale or, it seems, a lifestyle, it's not clear.