In which states? I've never heard of an instance where any state legislature passed a rule that forbids employees from discussing politics. I'm surprised there wouldn't be massive outrage over it.
There is no federal law that prevents employer discrimination based on political beliefs. There are some states, specifically California in this case, that prevent employers from discrimination based on political activities and/or affiliations. However, most states prevent employers from controlling political activities outside of work
The First Amendment does not apply to private institutions, only public ones. Private institutions can outright ban political discussion with no repercussions and cannot be liable for termination on the grounds of political beliefs expressed within the workplace sans some states.
So while it isn't "illegal", it can be restricted within private companies.
I think you're confused. It's definitely not illegal in any state to have informal political discussions with coworkers. Maybe what you're referring to is that it's illegal for employers to tell employees to vote a certain a way or retaliate against them for holding certain political views.
Only in some states is this legally protected. If a private company allows it, then there is no problem.
However, most private companies don't allow political discussion and it's not illegal to control this unless you live in certain states, California being one of them.