A whole string of people decide after taking a risk assessment into consideration. When cases go to court, all sorts of information or reports will be gathered on the individual.
I suppose you could say it down to Human Error?.
Perhaps going of subject slightly, before the days of video links, transportation for court appearances were more frequent than what the public were aware about. The higher category the prisoner, the much bigger the risk, and the more security was provided, including armed officer's.
Again going off subject slightly, I recall the early days of contracting-out prisoner transportation. The vehicle being provided in the early days, had insufficient vehicle suspension built into the design. The old hand or 'lags' knew about this, and on occasions used it to their advantage. Nothing like having a driver requesting police action, because their vehicle was becoming far to dangerous to drive. With the result that prisoner's might escape?.