If you are a developer and worked on a code for 2 years. NDA cannot cover what you know what you don't. Your know-how that you captured on that company can simply be replicated in another company. You'll write the code from scratch, and NDA or copyright, or even patent in majority of the cases will not be enough to enforce or stop such a think. In rare cases patent can solve it but do we want all companies to patent everything?
While employed, a person necessarily learns skills in order to perform their duties; as an employer, it would be impossible to derive value from the worker without training and knowledge transfer. Your argument is that it should be a two-way street until employment is terminated, then it becomes a one-way restriction against the employee. That's not fair to workers and is extremely biased toward the employer.
Employer pays the time for that employee to acquire the knowledge, employer serves the know-how that the employee might never ever able to learn by herself. How is it not reasonable to expect that knowledge to be used against the employer? Why is it one-way? I'm not talking about knowledge in a sense that "good code should include comment" kind of dev best practice. I'm talking about domain specific know-how that the employer came up with in many years by spending lots of money (R&D, trial & error, field studies etc).
Since the secrets aren't yours to share at will, they belong to the company, there's nothing that restricts your freedoms in an NDA. It's more of a covenant than a restriction. You're making a legally enforceable promise to not spread about things you know full well are supposed to be confidential. A non-compete however restricts your freedom of movement in the labor market and directly provides a tool for the employer to coerce your actions in and outside of work. There's a huge difference in consequences and incentives, while the NDA provides sufficient protection for the things that matter in your scenario.