In the first game, you seal all the keyholes, beat Ansem, the end, right? In KH2, you seal more keyholes and defeat more heartless, why? Weren't the keyholes sealed and the heartless beaten?
Heartless in Kingdom Hearts II are released by Organization XIII.
With Roxas and Xion gone and Sora awakened, Organization XIII begin manipulating Sora into collecting hearts for Kingdom Hearts. They release Heartless into many worlds, forcing Sora to fight and defeat them (source)
The Heartless invade worlds and search for their Keyholes. Upon discovering the Keyhole, the Heartless will enter it and eventually devour the world's heart.
So basically, the keyholes that are being sealed are simply to stop the Heartless from attacking the heart of the world. Once the keyblade locks it, it is assumed that it cannot be re-opened.
This would bring the question of why Organization XIII was invading worlds that were locked out. As Nobodies, their ultimate goal was to become whole by reclaiming their hearts via Kingdom Hearts. The way they could get to Kingdom Hearts is to get more Hearts by defeating the Heartless.
Emblem Heartless defeated by the Keyblade give up the stolen heart, which causes it to return to the owner's original body. Heartless slain by another weapon return to darkness and eventually reconstitute elsewhere. However, in Kingdom Hearts II, the hearts went to Organization XIII, who captured the hearts within usually unseen dark corridors in the sky. (source)
Also interesting to note, keyholes were not closed in Kingdom Hearts II.
Instead of sealing the Keyhole of a world, Sora opens the world's Gate, which reveals a new path to a different world. Curiously, though several never-before-seen worlds appeared in Kingdom Hearts II, not one of them had their Keyholes sealed, mainly because after End of the World was destroyed, all worlds went back to what they used to be, and the newer worlds therefore had no reason to be sealed by a Keyblade (source)
Yen Sid Answers this question, The Thing is Yes the Key holes were sealed no the heartless weren't beaten they did however Prevent a higher amount of heartless being around but heartless are going to be around as darkness still lurks in the hearts of many overall I highly doubt you can truly wipe out all heartless