It was an illegal act, funded by public money. Had the government not acted, it would have set a bad precedent: that constitution doesn't hold weight in real life.
I don't think the use of public money for the illegal act necessarily sets a bad precedent. The constitution didn't say to go out there and spray rubber bullets at civilians. So how a government can respond to this illegal act is a subjective choice.
Spain could have chosen to use less authoritarian methods to deal with the consequences of this ballot without setting any precedents. It could have been declared unenforceable by a court, which is a more appropriate venue.
Nobody expected them not to react to the referendum. Using cops with clubs instead of lawyers was disappointing.
>that constitution doesn't hold weight in real life
We will see what carries more weight, violence or paper.