It’s more like when you work for the government, you’re allowed to say what in a personal context. Once you start throwing around a title linked to the government, you’re no longer speaking as yourself, youre speaking as the government. The government can tell you what the government is allowed to say.
It’s the difference between an employee of the coast guard joining Greenpeace vs. That employee publicly saying the United States Coast Guard is joining Greenpeace. The coast guard can’t fire an employee for their own political beliefs, but they can totally fire a guy for saying shit the coast guard doesn’t want while representing the coast guard. Public speaking and seminars and shit like this have explicit rules about who can say what and when as a government employee in an official capacity.