For a little more description (fully my long-winded theories and opinions here.)
That is basically the simplest definition: a puzzle is an obstacle of some kind that isn’t generally found in normal literature. The most common type of puzzle in interactive fiction is lock-and-key: “here’s something locked, you must find the key to unlock it.” This needn’t always be a literal lock and key - the key might be a tasty bone and the lock an angry guard dog - you give the bone to the dog as distraction so you can proceed.
Standard literature is a mostly passive experience: you read a story about characters doing things. They may encounter obstacles and decide how to overcome them, but the reader has no input. In The DaVinci Code the characters encounter and solve actual puzzles and mysteries fully on their own, though the reader might figure out what they need to do ahead of time, providing some extra immersion with the story. Or the reader might deduce and predict the outcome of a mystery before the denouement, but are basically passive witness to how the plot resolves.
Ergodic literature requires some additional action other than linear reading. There are experimental books where you might have different versions of the story on alternating pages from different character perspectives, or parts of the book might be printed backwards requiring you to hold the pages to a mirror. S is designed as an old library book but is filled with handwritten side notations in different color inks from multiple other fictional characters who’ve ostensibly had possession of and read the same copy of the book you’re holding, telling a parallel story to the printed narrative. The pages are filled with loose artifacts these characters have left for each other: postcards, tickets, a diner napkin with a drawing on it that the reader can gain extra detail from. House of Leaves is about a house that is bigger on the inside, and the book mirrors that, requiring active navigation from the reader to get through its multiple fonts, multiple points of view, unique page layout (upside down, backwards, weird paragraph shapes, a maze of footnotes) which actively resist the reader navigating straight through.
Choice narratives, best known in paper form as the juvenile literature series “Choose Your Own Adventure™” are often in second person “You see a castle in the distance.” and require the reader/player to make choices that may alter or branch the story. “If you open the left door, turn to page 45. If you open the right door, turn to page 106.” These are a specific form of ergodic literature, and the decisions the player make could be considered “puzzles” if there are good or bad outcomes based on the choices. “You see a hungry man-eating plant. If you ignore it and walk over the vines, turn to page 38. If you’ve found the weed-killer you can use that on the plant by turning to page 96. If you retreat, return to page 19.”
Parser interactive fiction such as Zork provides a navigable map and a world model, allowing the player to experiment with objects, locations, and other characters in a way that controls and directs the story. They may need to solve a puzzle, say to prevent the Thief from stealing important objects they need, or navigate a maze to discover new areas.
Interactive fiction usually employs these types of puzzles for different reasons: Some games are a fun gauntlet of logic puzzles to solve that may have little to do with any plot. Puzzles can be diegetic - you must find a key to unlock a door to proceed; you need to assemble five broken pieces of a generator to restore power and lighting so you can explore dark areas; you need to discover who killed Colonel Dijon by completing a series of tasks and make discoveries that lead to the identity of the killer and their methods which you must report to your superior to win the game.
One major use for puzzles is “gating” where you must solve enough puzzles in an area to learn enough about the plot so you can proceed to the next area’s puzzles that continue the plot. An example in graphic adventures is “The Three Trials” in Curse of Monkey Island where a panel of Important Looking Pirates requires you to accomplish three tasks to prove you’re a worthy pirate and can captain a ship, which gives you access to new areas. These trials require the player to explore the map and meet other characters in the process, providing story structure the player needs so the story doesn’t occur out of order. Puzzles can be conversational - your discussion with the guard may get them on your side so they’ll let you access a location, or making them angry could incite them to bar your way or even attack you.
Puzzles are often considered the “meat” of interactive fiction, but there are also interactive narratives that are fully explorable with no puzzles that imply a story through world building. The player will still make decisions - where to go, what to examine, but they aren’t restricted from any interactions by puzzles.
In general for IF “puzzle” is a catch-all term meaning “something the player must figure out or solve to proceed or that will provide knowledge to proceed.”