Originally formed for self-protection, prison gangs have become the unlikely custodians of order behind bars, and of crime on the streets.