Overcrowded and understaffed jails are breaching prisoners' human rights, with some subjected to "inhuman" treatment as cases of self-harm rise.