If you remember key points in both the first and second film, they say that Smaug has not been seen for sixty years:
"That dragon had slept for sixty years," - Elrond. "The Great Dragon Smaug has not been seen for sixty years," - Thorin.
In the second film, if you look carefully at when Smaug bursts out of the mountain, you'll see that he smashes his way through rocks and stone in order to get out. Quite easy for him, not so for dwarves. My guess is that before he went into the sixty year long sleep, he sealed himself in to better protect his horde of treasure from would-be thieves while he slept. It was easy enough for him to get out, but no one else could ever get in.
This is just my take on it. The books (which I haven't read) might be completely different.