I do not know the easons why Smaug was depicted as having only two legs in the second and third Hobbit movies.
But if being faithful to the book is considered desirable in the Hobbit movies, changing Smaug from four legs to two legs should be considered an error. I think that it is absolutely certain that Tolkien always imagined that Smaug had four legs, and that the movies thus drastically changed Smaug's physical form from the book.
Dragons are often depicted as snake-like or lizard-like creatures.
Snake and lizards are quite closely related creatures. They resemble normal quadrupeds in many ways; both snakes and lizards have heads attached by necks to torsos that in turn are attached to tails.
The torso of a lizard begins with the shoulders where the neck and the front legs are attached and ends with the pelvis where the back legs and the tail are attached.
And that is also true for snakes. The torso of a snake begins with the shoulders where the neck and the front legs are attached and ends with the pelvis where the back legs and the tail are attached.
You say no, snakes don't have legs attached to their shoulders and pelvises. Actually some "primitive" snakes like pythons and boa constrictors have vestigial limbs remnants within their bodies, and even having spurs sticking out from their pelvic areas. The hearts, lungs, intestines, etc. of snakes are usually within their torsos and not their necks or tails.
In medieval English, "worm" meant a long, cylindrical animal, like a worm, a snake, or a dragon. And medieval depictions of dragons depict them with no legs, two legs, or four legs, with no wings or legs, with wings and no legs, with wings and two legs, with wings and four legs, etc.
And Tolkien certainly was familiar enough with medieval English to know that all dragons were "worms", regardless of how many or how few limbs they had.
Tolkien wrote a scene in The Hobbit where Smaug is described as "The Worm of Dread":
But that certainly would not inhibit Tolkien in describing or depicting Smaug with wings and legs.
In the Silmarillion the first dragon to appear during the First Age was Glaurung.
Names, epithets & titles
As the first and greatest of the dragons of Morgoth, Glaurung was sometimes referred to as the Great Worm,[3][4] the Worm of Morgoth,[5] the Great Worm of Angband[1] and the Gold-worm of Angband.[6] He bore the epithets the Golden,[7] and the Deceiver[source?] (the latter presumably referring to his dealings with the children of Húrin). He was also described as the Father of Dragons[7] and the first of the Urulóki,[8] though whether this implies he actually sired the rest of his kind is uncertain.
http://tolkiengateway.net/wiki/Glaurung
Glaurung was wingless, and the first flying and winged dragons did not appear until the Great Battle at the end of the First age.
Although Tolkien described Glaurung as wingless, and as a "worm", Tolkien depicted Glaurung as having four legs.
Here is a link to an image of Thror's Map from The Hobbit. It has a drawing of Smaug at the Lonely Mountain. But it also contains another drawing of a dragon, near an arrow pointing left (to the north in this map) and a legend "Far to the north are the Gray Mountains & the Withered Heath whence came the Great Worms." And there is an image of a great worm, wingless, but with four legs. http://tolkiengateway.net/wiki/File:J.R.R.Tolkien-_Thror%27s_map.jpg1
Here is a link to an image of "The Death of Smaug" by J.R.R. Tolkien, clearly showing Smaug flying, with two wings and four legs.
jmbpiano's comment to this answer also points out that Tolkien mentioned Smaug's "foreleg", a phrase which strong implies that Smaug had rear legs.
Here are links to other images of dragons by J.R.R. Tolkien, showing winged dragons with four legs. In short, J.R.R. Tolkien always drew dragons, both winged and wingless, as having four legs.
Some have suggested that Tolkien's picture "Conversation with Smaug" shows Smaug two legged. You will note that Smaug is coiled around a pile of treasure and that only his head, neck, tail, and the forward part of his torso are visible. The rear part of Smaug's torso, where his hind legs would be expected to be attached, is hidden behind a pile of gold, silver, and jewels.
A pair of legs is shown attached right in front of where the wings are attached. I would expect that most drawings of two legged dragons or wyverns would show the wings attached at the shoulders and the legs attached at the hips, like birds and bats and prehistoric flying reptiles. It would be very unusual to depict a wyvern with the hind legs turned into wings instead of the forelegs.
So I think that Smaug is depicted as a four legged dragon in "Conversation with Smaug", and the idea that he might be two legged there has never occurred to me before reading the answer where that is suggested today.
And you may remember a verse from the song in "an unexpected party":
The mountain smoked beneath the Moon
the Dwarves they heard the tramp of doom.
They left their hall to, dying, fall
beneath his feet, beneath the Moon.
Some of the Dwarves who sung that were witnesses. So apparently Smaug crushed many Dwarves to death beneath his mighty feet. Maybe Smaug had only two feet and held the front of his body far above the Dwarves on his forelegs while the rear of his body dragged on the ground. But Smaug's belly was soft and unarmored and could easily be pierced by axes, swords, and spears. So it seems likely that Smaug was standing high on four legs with his belly out of reach of any Dwarves trying to stab him with spears like Elaezar Maccabeus at the Battle of Beth-zechariah.
So if Smaug was depicted with four legs in the first Hobbit movie, it was because the filmmakers assumed that all dragons have wings and four legs, or else because they were familiar with Smaug with the book and knew that in the book Smaug had four legs.
Therefore, the special effects team deliberately changed the appearance of Smaug for the second and third Hobbit movies, for reasons discussed in other answers.
The purpose of my answer is not to discuss the decision making for the change in the Hobbit but to prove that - to the degree that someone thinks that the Hobbit movies should be faithful to the book - that decision was an error.