Something like this could happen once within reason, even once in awhile. I would take 1 of 2 actions:
1) Wait and see if this is the pattern without raising the issue at all. If you see NPCs solving problems consistently while your characters struggle to get a sword in edgewise, then simply quit.
2) Discuss it with the DM yourself, one on one and politely. There is no need to be confrontational. You could ask him what is philosophy is on the subject. Few DMs would say outright that they live to steal the thunder of the party, but if he states explicitely that he doesn't believe in that sort of thing, then it will weigh in his mind the next time the prospect comes up. Alternatively, you could simply explain that you do not really enjoy campaigns where the NPCs solve all the problems. You don't even need to call attention to the previous conflict or put him on the spot, just state a clear preference and let him think about it. As with option # 1, if the pattern continues, then you can leave then.
Faced this problem myself recently and used option # 1 myself while watching an epic demon fight a good dragonus ex machina while the 10th level party struggled to add a nickel or a dime to the overall damage. It was the umpteenth time in that campaign that we we put way over our heads and then rescued, and I was just tired of being a spectator. Once or twice is no real problem, often thankful for the help. Standard Operational Procedure = I'm out. Today, I would probably use option # 2, just discuss it once and ask the DM to rethink his approach before walking out. Don't know if that would have worked, but it might have. Not working would have worked out about the same in any event.
As a side note, I think the notion of overwhelming the characters in a single game then letting an NPC handle it might serve a constructive role early in the campaign. It's sort of like showing them how far they have to go, giving them a base line against which to measure their progress. So, you can later say, "remember when we couldn't even handle a pack of lousy ogres, hehehe!" [/Oldfartvoice] It really is a common narrative theme, getting your butt saved while still learning the ropes. But I would also make a point to throw something characters could handle their way in the very same session, something to give them a sense of accomplishment. If the same thing is happening several levels down the road, then you have a real problem.