Actually, they use the two leg version for some games and things where the Koopa's need hands (like Mario Kart Wii)
And, the only game I recall with the four legs is the galaxy games.
The koopas always have 4 legs, it just depends on whether they use them or not.
I'm guessing their design just evolved. A lot of enemies looked different in their early appearances than they do nowadays. "Crawling" versions appearing in more recent games are probably references to their original Shellcreeper-like design; Nintendo likes to put references to earlier games everywhere, especially the NES era ones. Certainly doesn't make much sense "in-universe", but very few things about the Mario series do, and it doesn't really try to be anything more than a video game series with little to no continuity, so there's nothing wrong with that.
Well they walked on 4 legs in the older games and became bipedal in most of the newer ones. I think when they walk on 4 legs in the new games like in Galaxy it's just a reference to the old style of koopas. They walk on 2 legs except in space I guess. Maybe those are space koopas.