You gleefully say, "I just thought of something!", when in fact your brain performed an enormous amount of work before your moment of genius struck. When an idea is served up from behind the scenes, your neural circuitry has been working on it for hours or days or years, consolidating information and trying out new combinations. But you take credit without further wonderment at the vast, hidden machinery behind the scenes.
You've got to be pretty confident that you're good. If I do a show and for whatever reason no one laughs, I'll be like, 'Wow, those people are weird'.