When you EXAMINE something, Inform first checks to see whether the description of that thing is empty or not (i.e. compares it with the empty text). In doing so, it expands out all of the text substitutions, though without printing anything. That causes problems in cases, like this one, where those substitutions are causing things to change in the game world; because when Inform comes to actually print the description, it’s actually the second time those substitutions have been expanded.
This can be avoided using the “[if not expanding text for comparison purposes]” substitution. (I don’t think it’s documented in Writing with Inform, though it very definitely ought to be.)
A new textbook is a thing in XXX. The description is "It's just a copy of the same textbook you use in proctology class[period]
[if we have not examined the missing page]Maybe you can find the page that was missing from your textbook? You open the
book to get a look, and indeed there it is--[otherwise]You open the book to read the page again--[end if][if not expanding text
for comparison purposes][exmpage]".