The index creation itself is a separate special task which takes place after the print typesetting is complete with a final print PDF. This final print PDF is what is used to create an index. Once the index is complete, it’ll be added as the very last page of the typeset and a new print PDF is created that includes the index will accurate page locations and entries.
Indexes are quoted after the print typesetting is complete, because it’s dependant on the final page count and the amount of indexable pages inside the book.