If your manager says your performance is based on lines of code, you will be incentivized to write lots and lots of code. Does lots and lots of code mean you are being productive and making good software? Sometimes yes! Sometimes heaps of code means you are being ultraproductive and making amazing software. It could also mean you are writing much more code than you need to, introducing new bugs, not thinking about generalizing patterns, creating technical debt, making a worse UX, all of which I'm guessing you would agree are important to software engineering. But none of those things are going to matter in the lines of code metric.
So yes, sometimes having metrics for performance are worse than imperfect. Sometimes they are antithetical to the supposed goals. Student time is a zero sum game, and having a large portion of a crucial time in their development spent cramming for one metric is not going to have good outcomes for a society, only good outcomes for a metric.