As @Jen tried to point out, you are conflating multiple legal issues. NDA is an acronym for "non-disclosure agreement". In brief, the company asking you to sign the agreement may be telling you things that they want held in confidence. If you sign the NDA you are agreeing that you won't disclose the things they tell you to anyone not cleared by the NDA. This may be proprietary technical information: "We use Lempel-Ziv for our compression algorithm" or it may be "We are embarking on a new line of business.", or even "We are going out of business". The key is that it is information they provide you. If the company wants to sue you for breaching it, they have to establish that it was something they told you, and you told someone else. How the court decides such a suit depends on evidence, and lots of prior applications of the law. However, if they try something silly like "We told the signer about 'for' loops in Python" they would be bounced out of court. You could also keep using Lempel-Ziv compression in other programs you are working on, you just can't tell others that the company whose NDA you signed uses Lempel-Ziv. If it comes to a lawsuit then the jury may be asked to look at emails or even source code (usually assisted by expert witnesses) and decide whether the NDA was violated or not.
Beyond an NDA the company may be worried that you could walk out the door with the experience you gained while working on their software, and take your expertise to a competitor. The answer to this is a "Non-compete" clause. How seriously a non-compete limits you depends on where the contract was established. Famously California will usually not enforce non-compete clauses in employment contracts.
Separate from both of those are copyright concerns. If you are a wage worker copyright of the code you create generally goes to the employer. If you are a contractor copyright generally remains with you unless otherwise specified by your contract. Again, if it comes to a lawsuit the court may end up looking at the source and making a judgement about whether any copyright infringement is substantive (say an entire library of compression code) or trivial (everybody uses for-loop).
In the comments you use the example of a printer driver. Suppose you sign the NDA and the company tells you "We previously have found a super efficient way of communicating with the printer using an undocumented OS call, which the OS vendor assures us will be supported forever", you had better not disclose that that to anyone else. Or if they tell you "We're going to write our printer driver in Rust instead of assembly", don't tell anyone that's their plan. If you sign a non-compete then you probably can't go to work for another company doing printer drivers for a fixed period of time. If you are a wage employee and you write them a whizzy printer driver completely from scratch, not using any secrets they told you, then the company almost certainly owns the copyright to that code. If you end up going to another driver vendor you'll have to find a new way to write that driver code because if you substantially duplicate your previous work that will probably be a copyright violation. On the other hand if you are a contractor and your contract doesn't otherwise specify any limitations or transfers of copyright, you can cut and paste that whole library you wrote.
I should also add that NDA are not all the same. They vary widely in what information they cover, terms of coverage, penalties, etc. If you are a software developer asked to sign an NDA you may want to run it by a lawyer before signing. Here is an article containing more info on NDA for software engineers.