Let me give a very simple version of what has already been said:
The oracle said it in her kitchen to Neo that Smith was him, his opposite, his negative.
When Neo became Smith they had become one it became the conduit which allowed Neo to spread to everyperson Smith had infected. But Neo had an advantage - Neo's mind could touch the Source, and now that he was ready for it he could survive the encounter. Smith could not , he wasn't ready or prepared for it, didn't evenn see it coming.
We can never see past the choices we don't understand. But at that moment of clarity and understanding after the Oracle's words through Smith, Neo could and thus knew what to do.