The return of your iCloud notes happens because turning off the iCloud switch on your device only disconnects the phone from the cloud; it does not delete the data stored on Apple’s servers. Even if you never upgraded your plan, those old notes remained safe in the cloud. When you restored your phone from the backup, the device likely logged back into your Apple ID, re-established the connection, and immediately downloaded the existing notes from the server.
Regarding your missing "On My iPhone" notes, since they are local files, they should have been included in your computer backup. Their disappearance is likely due to a settings reset or a display glitch rather than data loss. First, navigate to Settings > Notes and ensure the toggle for "On My iPhone" Account is turned on; sometimes a restore disables this feature, hiding the notes that are actually there. If enabling that setting does not bring them back, the notes are likely trapped inside the backup file but failing to index on the phone.
To recover them without risking further data loss, do not restore the backup to your phone again. Instead, use a backup extractor tool (such as iMazing or iPhone Backup Extractor) on your computer. These programs allow you to open the backup file directly and view the raw database. If the notes were successfully saved to your computer before the restore, you will be able to see them within the software and export them as text or PDF files. This is the most reliable way to retrieve the data when the iPhone interface fails to display it.