"I have YOUR magic, remember? It doesn't work in the dream realm!"
I want to unpack this little comment by Luna, because it contains some heavy implications about the two Royal Sisters, Nightmare Moon, and the Dream Realm.
If we take Luna's statement at face value, it means the ability to enter the Dream Realm and confront ponies' nightmares is tied directly to Luna via her cutie mark. No other pony, not even Celestia, has this power. This raises the question: what was going on in the Dream Realm while Luna—as Nightmare Moon—was banished to the Moon for a thousand years?
In the waking world, Celestia could banish Luna/NMM physically, but she has no power in the Dream Realm, no way to control her sister there. This would suggest that Nightmare Moon was running amok in the Dream Realm for a thousand years, which doesn't seem supported by the show. Instead, the show treats Luna's dream-walking abilities as something ponies have always known, unconnected to her evil alter-ego.
The only logical answer I can think of here is that Nightmare Moon only existed in the waking world, and Luna/NMM's banishment was also only in the waking world. In the Dream Realm, Luna was still Luna, still herself, uncorrupted by her nightmare form. Though her body was imprisoned in/on the Moon, her spirit could still wander through ponies' dreams and guard them against nightmares the way she always had before. She probably visited Celestia's dreams many times, and those had to have been extremely uncomfortable for the Sun Princess:
"Why is my body imprisoned, sister?"
"Because when you wake up, you're a monster."
not provided yet