Wesley. I'm a rogue demon hunter now.
Cordelia. Wow. so, what's a rogue demon?
This typically occurs through the use of multiple nouns, verbs, adjectives, etc, in the same sentence, in such a way that it's difficult or even impossible to determine which adjective, verb, etc, applies to each noun. As a result, it's possible to interpret the sentence as having two or more meanings which are sufficiently different that the difference could potentially be very important to the reader or the plot. In some cases, there is only only one technically, grammatically, or logically correct interpretation, but it's so easy to misinterpret or mis-write that most people end up getting it wrong at first. In other cases, multiple interpretations are arguably grammatically correct.
In both Real Life and fiction, this is usually Played for Laughs. because the incorrect interpretation typically leads to an absurdity. A "man eating chicken" (note missing hyphen) seems to be an especially popular variant.
Another popular comedic variant is "You see this
object here? When I nod my head, hit it as hard as you can."
On a more serious note, however, ambiguous syntax is sometimes used in false advertising so that the advertiser can claim they explained everything, and it was the consumer's fault for misinterpreting the statement. Likewise, in myth and legend, prophecy often includes ambiguous syntax, to make it more difficult to determine the exact details of a predicted event until it actually occurs. It is especially abused by the Literal Genie. to grant a wish in a way not intended by the speaker.
The Other Wiki lists more examples here. Note that this is easier to pull off in English than in most other languages, because English has neither grammatical genders (in French, for example, you would know that the feminine adjectives could only apply to the feminine noun) nor cases (in German, you would know that the dative adjectives could only apply to the indirect object of the sentence), leaving a lot more room for ambiguity.