Most contributors tend to follow the rules of a project. Some will skirt them, some AI code will probably get in, but a ban will certainly limit it, and certainly look better in court compared to "We made it a rule that it's okay to not disclose that you used the likely copyrighted code generator".
Take for example the WINE project, which has a strict ban on anyone who has seen the Windows source code from contributing to the project (such as an ex-employee or someone who has seen the source code from a leak). This is obviously impossible to enforce; how could they reasonably prevent a microsoft employee from submitting code that might be infringing on Microsoft? They can't. But their ban will certainly aid them in court if MS ever did sue them for infringement. and I think it likely anyone who had seen the source code and wanted to add a patch would respect the rule. It's not perfect protection, but it's certainly better than "If you submit windows source code, just don't tell us, and hopefully we won't get in trouble".