They run special builds during the demos that presumably only have a portion of the functionality to ensure that no bugs pop up. You'll notice that they stick very closely to a script that is on the desk while they demo - sometimes you can see them looking at it and flipping the pages.
It also helps that they rehearse until their hands fall off. Aside from the actual responsiveness of the device or OS, it helps when you know exactly when, where, and how to manipulate it to make it look best on stage.
They'll iron out the bugs throughout the beta phases.
Not only that, but it's been confirmed that the iOS Beta version they ran was newer than what was released to the developers.
I work for a software company, and for critical demos of radical new software developers very often compile special builds with very specific hacks to make sure that the demo runs smoothly. A lot of things are faked - like what you think is actual code running could be just a screenshot of the result compiled into the code that's shown when you press a button. When normally slow operations run super fast, they usually just fake it and jump to the result screen. Wow, it runs so fast!
Those builds certainly wouldn't work for general OS usage. I'll bet if you did things outside of their careful demo steps things would most certainly fail and crash and burn.
Demos run by company people have a lot of fake stuff in there. Ever wonder why they never let the public try it out at the show?