I can easily see how it started out as a legitimate piece of work and then got subverted by a small coterie of top level managers and a few on the code development side.
The auto companies repeatedly test the cars on their test bench. They use specially instrumented engines that collect so much of data on those test cars. Knowing which data was collected on the test harness and which were real road data is a legitimate data for debugging and fine tuning. The amount of data collected (actual valve position, commanded valve position, sensed crank angle, actual crank angle, time fuel injector open, time fuel injector done, blah blah ...) would so copious they might turn off certain data collections under certain circum stances.
They might have started with a special manual switch on the dash to turn on "test bench" mode. They forget to turn it on a few times, invalidating lots of collected data because "on test bench" field was wrong. Some clever guy suggest automating it. All these would be very legitimate and most engineers on the team would be working on good faith that it is not a cheat device.
What I am trying to say is "auto detection of test bench run" has a legitimate purpose. They also have so many use profiles. CA air standards profile, Euro air standards profile, China air standards profile, India air standards profile etc. All these use cases are also quite legitimate. All the engineers working on all these projects would be doing work without compromising their integrity or ethics.
Eventually someone high up had a clever idea to load China/India urea use profile when the car is not on test bench. This work does not involve company wide collusion. It would require very few engineers on the coding side and a few top level managers. They would know what they are doing is implementing a cheat device. They might have even done it as a stop-gap measure intending to correct in a few weeks or few months.
Some scenario along the lines of ... "Heinz, the air-quality team needs a few more weeks, they are behind, we are going to miss the deadline. But they are close, just a few more weeks. For now let us load India profile when not on test bench, once the air-quality team finishes the project we can quietly restore the setting. Or we have to delay the ship date by a few weeks". "Erwin, are you sure they would be done in six weeks". "Definite, absolutely". "OK I will talk to Walter and Karl. Keep Adolf and Joseph out of the loop. Keep it under your hat, and make sure there is no paper trail".