Let's say I created a file compression library, and this library was used in 1000 (non malicious) programs. But now a malware developer has decided to create a malware and use my library to compress some files.
Based on my little knowledge on how an Antivirus works, it selects a group of strings of bytes from the malware and store it in its database. Now when the Antivirus scans a program that has these strings of bytes, it alerts the user that this is a malware.
But what if the Antivirus selected a string of bytes that corresponds to a portion of my library's code, wouldn't this mean that my library is now detected as a malware (and hence the 1000 non malicious programs are now detected as a malware)?
If an antivirus program flagged a widely-used piece of code as malicious, then yes, it would (incorrectly) detect lots of programs as being malware. But malware signatures aren't chosen at random; they're developed by human analysts who study the malware to learn what it does and how it works. Those analysts are careful to build the signature based on something that's actually specific to the malware, not a piece of non-malicious library code that happens to be included within it.