It does not automatically reinstall the OS. After you erase the Mac, Quit Disk Utility and select "Reinstall macOS" from Recovery macOS Utilities. Yes, it will take time since it has to download about a 6 GB installer and then install macOS. It could take a couple of hours. It is very important that you have a good backup before starting the process.
How to erase (format) the built-in startup disk of an Intel-based Mac.
support.apple.com
Use macOS Recovery, your computer’s built-in recovery system, to reinstall the Mac operating system.
support.apple.com