It's not clear to me how it is copyright infringement if the generated code is truly new. Of course, if some code output is very similar to existing code, then it is obviously copyrighted.
When you read code from an open source GPL repo and are inspired by it to write your own code, it's obviously not copyrighted.
Also, some people explicitly avoid reading codebases to avoid duplicating by mistake some copyrighted code.
Not sure if this is true but I heard that it used to be forbidden to Microsoft developers to read open source code.
ADDED: To be clear, it may be fine to say that making certain things opt-in means that other things that many might value can't exist.
This isn't the problem, it's the whole point.
Things need to be made opt-in because we want there to be a meaningful barrier to companies using data that does not belong to them in order to make money.
This is something Github/Microsoft started, something that only really benefits Github/Microsoft and that they were doing lackadaisical from the start by ignoring licenses.