2. It is fair that Bob and James received different punishments?
No, that's not right. The applicable principle is that, if cases can be distinguished on their material facts, they can be decided differently. Previous convictions are material to matters of sentencing because it is reasonable to punish a repeat offender more severely than a first offender. In this example, James has previous convictions for theft, whereas Bob has none. On this basis, the cases of Bob and James can be distinguished and treated differently.
Because James has been found guilty of theft on three previous occasions, it is fair to punish him more severly than Bob.