Plausible setup, closing frame swap in some tales
Some tales build a realistic frame across most of their length, so the reader settles on one interpretation, and then a closing line substitutes a different frame that still fits the stated facts. When this works, the laugh comes from the reader seeing that the certainty came from their own assumptions. Not every tale works this way, since 'Ferdinand' introduces its thinking duck near the start.