Reimplemented, not ported. They wrote it from scratch, using innovative techniques to get the smooth side scrolling that was supported by hardware in consoles.
Back in the day nearly every "port" was a full reimplementation, from the code to custom graphics and sound. Such are the perils of writing to bare metal.
There are lots of ports from the 8-bit home computer era which don't have this problem. See for example, the number of ZX Spectrum ports to the Amstrad CPC machines.
Commander Keen was an impressive achievement for the time, but it did not have console quality smooth scrolling. It ran at only 35fps, not the 60fps of the NES Mario games.
The earliest (better than) console smooth scrolling PC game I can think of is Monster Bash, which runs at 70fps.