There is more to freedom, or the lack of it, than physical mobility. He walked in and out of court so could clearly move around freely indoors, he could choose what occupations to occupied his time with; watch tv or a film, cook something for himself, choose his food. If he is in a care home, free to walk the corridors, choose who he does or does not talk to, who he sees and when, whether he goes out to see friends and family, even with help. He made his own personal spending decisions, could buy whatever took his fancy, even if someone else buys it for him.
He will now have all his self autonomy taken away, decisions will be made as to when he gets up or goes to bed, when and what occupations he can follow. When he washes, changes his clothes, who he mixes with. He will be very aware that his whole life is now fully in the control of other people and his ability to make personal decisions has been removed.
Punishment is also inflicted as a form of deterrence to other people and to make an offender 'pay' for their crime by suffering pain and incoinvenience, not pain in the physical sense but the pain and problems of having their freedom severely restricted.