In Kirby's adventure, Dedede worked FOR the
nightmare, but in Nightmare in DreamLand, he's been working
AGAINST the Nightmare. My theory is, he was tricked by a
costumed worker of the Nightmare -perhaps the NightMare
itself- to hide the Star Rod and the villian in the costume
told him where! So DeDeDee was
tricked into working for the
nightmare, he just didn't know it!