The laws underlying those gag orders are also public, transparent, debated beforehand, etc.
The principle of the gag order comes from the implementation of the law. Obviously the public law itself allows gag orders, otherwise Google's lawyers would tell Google to go ahead and publish them. Gag orders have been around in America, at all levels of law enforcement and security, since waaaaay before all this.