Putting an NPC in trouble is a valid move in PbtA.
Technically, neither Gandalf nor Frodo are PCs or NPCs, which points to an inherent limitation in mapping a story onto a D&D or a PbtA system.
More importantly, the book explicitly says that it is valid and appropriate for the bad consequences of a move to fall on a different person if the situation calls for it. For example, there's a reference to someone losing a spell they had cast, which was helping a second character, and the GM then turns to that second character and says, "You were relying on that spell. What do you do?"
If we parse the Moria scene in PbtA terms, knowing that the analogy will be imperfect because fiction isn't identical to gameplay:
The party has just finished a fraught Undertake a Perilous Journey, where the Trailblazer rolled poorly (mountain pass cannot be taken due to unnatural weather!) as did the Scout (no forewarning of the Watcher in the Water), but the Quartermaster did fine (they aren't going hungry.) They are delayed and frustrated but in good spirits otherwise.
Gandalf knows there's a secret door here, and begins asking questions and trying various means to open it. Unfortunately, even though he has +3 Int and such, he actually manages to botch his Spout Lore roll, and the GM narrates something like the following:
"Gandalf, you've gone up against some tough magical wards in your day, but this one is clearly beyond any you've faced. Hours and hours—precious time—is wasted on incantation after incantation, seemingly to no avail. You know you'll crack it sooner or later...but 'later' is becoming 'much later.' Eventually, even watching your magic work ceases to provide an interesting diversion. Merry and Pippin, this was supposed to be your
adventure, your chance to be like Cousin Bilbo and do crazy impressive things that would get rumors about you for years. How do you handle the sheer, unadulterated
boredom?"
And then from there the Hobbits disturb the Watcher (which I doubt would even trigger any moves), and you thus have a fun "escape from the monster" scene. Then Merry gets a partial success (in theory it could be full, but partial fits better) on Discern Realities and asks, "What here is not what it appears to be?" regarding the door and its inscrutable riddle. "Gandalf, the instant the words have left Merry's mouth, you realize your error. It does not say 'speak, friend, and enter.' It says 'say "friend" and enter.' The password is just the elvish word for friend, 'mellon'! Ah, what gentler times these doors were made in." And then the Watcher starts up its business.
Again, not perfect. But it shows how you don't ever have JUST, flat, bare "nothing happens." Even a scene that
might become "nothing happens" is instead one that features a new danger, or puts something under threat, or presents an opportunity (with cost), or gives
some means for the action/drama/meaning to push forward.
There is no such thing as a dead-end failure, which is an unfortunately all too common event for many other TTRPG systems. That doesn't mean other systems cannot take steps to prevent the problem; far from it, advice on how to avoid the "party MUST get through the locked door but Rogue only has a 60% chance to pick it" problem is arguably one of the most common points mentioned for new DMs. But the fact that it needs such advice and is an effort to avoid shows the problem. System design can make problems like that go away,
building in the solutions that otherwise have to be slowly sussed out by each individual GM.