If a few seconds' thought convinced the judge that there was failure to prove a key element of the crime, it is clear that the prosecutor had no evidence to back up that element, and therefore should be sanctioned for wasting the taxpayers' money and the defendants' time with a frivolous (and possibly malicious) prosecution.
Well, it's not a few seconds thought. It can happen when you try (defend) a case that you realize, at some point during the prosecution's case-in-chief, that he has made a fatal error or omission. And the judge may realize it, too. And so as soon as the prosecutor rests you make your successful motion to dismiss. The judge grants it summarily because he, too, has noticed the error, for some time, and when the prosecution rests it is, at that moment, TOO LATE to correct the defect.
So a judge can grant or decide immediately -- it doesn't mean he hasn't been thinking about it all the way through the case.