Since I worked on this SW I have to clarify a bit.
Lab testing of course does emulate real-world driving conditions. Otherwise your tests will not be worth much. Either you play back a recorded existing course (RPS - road profile sequences) or you simulate it, simple steady state and transient cycles. We are automating reproducible test conditions.
But we are here only talking about the different emission tests, where we have 2 major philosophies. The european emission test tracks (NECD), which is also used in India and Asia, which is an highly abstract test with the engine alone driven by a similator simulating multiple real-world driving conditions (a few urban cycles) and the american test on a dyno with a real driver (with varying cycles), so that the american car manifacturers, who traditionally were not so good in designing emission-free engines could traditionally cheat by hiring the best drivers to pass the test.
So Americans have cheated historically the most, but apparently engine manifacturers which couldn't catch up with modern diesel engine development had to cheat also. First it is trivial to cheat, since the test has to be done only once. This is entirely a political game to get the NOx and COx values down, but don't harm their own industries. And esp. Americans seldom use scientifically based values.
And then you have cold starts in reality, which is mostly not tested in the emission cycles tests. Emissions will always be higher in the field than with a properly warmed up engine under lab conditions. So it's no surprise that different measurement methods will lead to different results.