It's a natural progression from the original sense of the word mob.
Initially mob was a contraction of the Latin phrase mobile vulgus
, the fickle crowd. First cite for this in OED is 1688, under the definition 'a disorderly or riotous crowd, a rabble'.
Clearly it's not a large jump in sense to apply the term to a rabble of criminals, and this specific sense has an earliest cite of 1826 in OED.
5. a. A gang of criminals, esp. thieves.
1826 in G. C. Ingleton True Patriots All (1952) 109 The trial of Brady's mob.
A century later we find it being used in the originally American sense of a gang of organized
5. b. spec. orig. U.S. An organized association or gang of violent criminals; an organization engaged in large-scale criminal activity. Also (usu. as the Mob): the Mafia.
1927 Amer. Speech 2 385/1 Any kind of a gang was known as a push, a word credited to Australia, but I think it is a sister of the mob of the city underworld. 1929 D. HAMMETT Red Harvest ix. 91 He was in on the Keystone Trust knock-over in Philly two years ago, when Scissors Haggerty's mob croaked two messengers.