Hello, my beloved friend. I must let you know that, unlike the iPad, your Mac will not automatically update to the most recent version of macOS after a factory reset. However, you can choose the latest supported macOS for your MacBook during the process of factory resetting.
Let me show you how to factory reset your Mac and reinstall macOS in detail here:
Step 1: Erase your internal hard drive in macOS Recovery Mode
1. Press the power button to start your Mac and immediately press down Command, Option, and R keys together before your Mac chimes. These keys allow you to install the latest compatible macOS to your Mac.
If you want to install the current macOS that you're running, the Command + R keys are workable. If you want to reinstall the OS it originally came with, press the Option + Shift + Command + R keys, please.
2. Release the keys until you see a spinning globe and connect the Mac to the network if it isn't connected to a known network automatically.
3. Choose Disk Utility and click Continue in the macOS Utilities window.
4. Once in Disk Utility select Macintosh HD, or whatever volume you have called your Mac's hard drive, which contains your operating system.
5. Click Erase from Disk Utility's toolbar.
6. Name the volume and leave the format as APFS. Use GUID Partition Map as Scheme.
7. Click Delete Volume Group to delete Macintosh HD, Macintosh HD Data, and any other volumes you created.
8. Click Erase to confirm. After the erasing process, quit Disk Utility.
Step 2: Reinstall macOS
To reinstall macOS, select Reinstall macOS (almost following with the version of macOS) in the macOS Utilities window in macOS Recovery Mode and then follow the onscreen instructions to install a fresh copy of macOS on your Mac.