The thing is, in coding you have library calls. This is not present in art. You do not paint a thing and instead of a hand put a reference to the hand-maker with the parameter of 5 fingers. Reusing existing things is kinda the whole point of programming.
But if you rehash art, people get angry. For various reasons. Does not matter if you do it by hand or with extra steps of using a large language model. There will also be a line between copying/rehashing and actual learning how to do a thing. If AI crosses that line, it will be hard to argue that it plagiarizes by traning data. It will depend only on the results. A human can also plagiarize. But a human looking at art works will not be accused of rehashing those in memory to be able to reproduce those works.
As long as those systems put out the wrong number of fingers, they are quite on the other side of that proposed line. Or in case of code, your example with the wrong function. The training data probably had examples of those in a different context, but the AI did not grasp what you actually needed, it only gave you a thing that is probably similar to the answer by looks alone.