It’s not accidental. Not infringing copyright isn’t part of the objective function like it would be for a human.
If someone somehow managed to do that and then happened to have accidentally copied someone's code, how believable would their argument be?
No, and humans who have read copyrighted code are often prevented from working on clean room implementations of similar projects for this exact reason, so that those humans don't accidentally include something they learned from existing code.
Developers that worked on Windows internals are barred from working on WINE or ReactOS for this exact reason.