The law isn't written by the Spanish government either, it's written by Congress. A Congress in which nationalistic parties have more representation per number of voters than other parties with a higher number of total voters.
Insinuations that the judges in Catalonia are puppets of the Spanish government ignore the reality of Spain.