It would be a waste of time and money attempting to recover an overwritten document that was not backed up to to Time Machine. This is especially true if much time has elapsed since the overwrite, and whether any data recovery software could reconstruct a valid Pages document — which I doubt.
So this does not happen again, see Back up your Mac with Time Machine. You will need an external USB3 or USB-C external drive (depending on the available Mac port type) that is 2.5 - 3 times the storage capacity of your internal drive. You would use Disk Utility to erase that external drive as macOS HFS+ journaled (case-insensitive - default), with a GUID partition scheme. Mine is named simply TM. Once it is connected to your Mac, visit System Preferences : Time Machine, and click Select Disk… pointing it to your external TM drive. Then click Back Up Automatically. Also, select Show Time Machine in menu bar. You can see backup progress, and last backup timestamp.
Your first Time Machine backup will backup your entire Mac including the operating system. This will take awhile… . Approximately every hour that your Mac is powered on, and Time Machine is working, changes to your home directory, or operating system will get backed up. These incremental backups are smaller, and take less time.