I assume you open the file name for editing in the window title bar? There seems to be an issue with macOS that you MUST exit the edit field without closing the edit field to have the edited title stick. Use the <tab>-key after editing! This takes the input focus away from the field but does not close the edit panel. The new name now sticks and you can hit enter or whatever to close the panel.
It is a very annoying thing and happens to me all the time. Not only in Pages but in any program that supports this feature or editing the document title right from the window title bar.
I remember an issue some 20+ years ago with the very first versions of MacOS X where any textfield had this weird behavior. It was then said this was a legacy from NeXT. It was fixed pretty soon with an update to the OS. Interesting though that in one particular case (title bar editing of filename) it came back today.