Mandatory sentencing finds its way into legislation when the voting community believes that the judiciary is not doing their job in sentencing. A politician exploits the opportunity to get elected on that platform, and the electorate, frustrated at the softness of the judiciary, vote for them.
Ideally the judiciary would fulfill their obligations, but they don't for many reasons. One of which is that the the sentencing people judiciary are so far removed from crime themselves. They have large incomes, and they are well equipped to remove themselves (and their families) from crime. They move into low-crime neighbourhoods, live in very secure houses, don't have to take public transport and so on.
Wealthy and successful people require smaller punishments to deter them from crime. A wealthy and respected person would not dream of risking a week's prison for the benefit of stealing $100 from a parked car. Someone on a low income, with little social standing or compassion probably will. This is not to suggest that a wealthier person deserves a more lenient sentence, just that an affluent society needs smaller disincentives than a poorer one.
It is human nature to judge others based on one's own frame of mind, and one's own motivations, and one's own sub-society, and the judiciary are not immune from this. They are not part of normal society, they have their own sub-society. They do not understand the penalties required to deter criminals.
If they don't do their job, eventually the democratic process removes the responsibility from them.