Writing and magic involve many similar concepts, perhaps chief among them the concept of creative misdirection. The magician seeks to direct the audience's attention away from the spot where the sleight of hand is being performed. A joke makes the audience laugh at a critical moment, or the magician gestures broadly with his right hand while his left is working the magic. In writing, you want to distract, or misdirect, your reader away from the plot turn you're about to make. If the reader knows the plot turn long before it happens, the reader will be bored. Although this concept applies to all types of fiction, in fiction involving detection the writer points supicion away from the character who will eventually be shown to be guilty.
All scenes – and comic scenes in particular – rely on the concept of misdirection, of leading the character/reader to thinking one thing, only to let the action surprise them, leading to a reversal or a revelation.