Have to add my own anecdote to yours because this type of shifty behaviour is apparently common.
I was not hired as a developer, more like devops. But I ended up creating a lot of code. And through sheer principle I did it all open source. Created public repos of everything and then private branches for our internal Git.
Fast forward 7-8 years and we're using our parent orgs system to manage salary, vacation and stuff like that.
My manager wants me to approve something in this new system so I login and I'm greeted with a new employee contract.
The system says I have to sign this to proceed, and in this country we have digital identities so signing it would be as simple as taking out my mobile phone, starting an eID app, challenge, response, code, voilá signed.
Luckily I became very suspicious, downloaded the PDF version instead of signing it. Read it carefully, showed friends who are in the business.
Turns out it was the exact same clause, everything I create, on or off hours, belongs to parent org.
I simply refused to sign it and since I was already hired from a previous contract they removed the requirement from the system so I could proceed.
Now I believe this was a simple case of Hanlon's razor, but damn it would have caught a lot of less vigilant people.
And to be fair, I have nothing against keeping certain code private. If my employer tells me that a project cannot be open source then I will comply. But by default anything I write is open source unless anyone requests otherwise, or I consider it a bad idea due to some reason that is usually about security.