It’s not that they literally must work. It’s that they can be fired for not showing up despite going without pay. Any private employer could also try this, although it’s questionable whether or how long people would put up with it. When the government is the employer, there’s some level of confidence that at least you’ll get paid in the future, whereas with a private employer once they stop paying on time they usually are going to continue to have trouble making payroll until they fold.