You can read more detail in the letter from the EPA to VW:
http://www3.epa.gov/otaq/cert/documents/vw-nov-caa-09-18-15....Here is the explanation for what VW is accused of doing.
--- begin quote ---
Specifically, VW manufactured and installed software in the electronic control module (ECM) of these vehicles that sensed when the vehicle was being tested for compliance with EPA emission standards. For ease of reference, the EPA is called this the "switch". The "switch" senses whether the vehicle is being tested or not based on various inputs including the position of the steering wheel, vehicle speed, the duration of the engine's operation, and barometric pressure. These inputs precisely track the parameters of the federal test procedure used for emission testing for EPA certification purposes. During EPA emission testing, the vehicles' ECM ran software which produced compliant emission results under an ECM calibration that VW referred to as the "dyno calibration" (referring to the equipment used in emissions tested, called a dynamometer). At all other times during normal vehicle operation, the "switch" was activated and the vehicle ECM software ran a separate "road calibration" which reduced the effectiveness of the emission control system (specifically the selective catalytic reduction or the lean NOx trap). As a result, emissions of NOx increased by a factor of 10 to 40 times above the EPA complian levels, depending on the type of drive cycles (e.g., city, highway).
--- end quote ---
And here is what happened when this was found out and the EPA and CARB tried to find out what was happening:
--- begin quote ---
VW continued to assert to CARB and the EPA that the increased emissions from these vehicles could be attributed to various technical issues and unexpected in-use conditions. VW issued a voluntary recall in December 2014 to address the issue. CARB, in coordination with the EPA, conducted follow up testing of those vehicles both in the laboratory and during normal road operation to confirm the efficacy of the recall. When the teting showed only a limited benefit to the recall, CARB broadened the testing to pinpoint the exact technical nature of the vehicles' poor performance, and to investigate why the vehicles' onboard diagnostic system was not detecting the increase emissions. None of the potential technical issues suggested by VW explained the higher test results consistently confirmed during CARB's testing. It became clear that CARB and the EPA would not approve certificates of conformity for VW's 2016 model year diesel vehicles until VW could adequately explain the anomalous emissions and ensure the agencies that the 2016 model year vehicles would not have similar issues. Only then did VW admit it had designed and installed a defeat device in these vehicles in the form of a sophisticated software algorithm that detected when a vehicle was undergoing emissions testing.
--- end quote ---