How to restore Macbook Air to factory settings?
Your answer is right there in your last line, "format the MacBook Air..." Or more correctly format the hard drive.

When you boot into Recovery Mode you should be given the option to launch Disk Utility. Do that, go into Disk Utility, select the Macintosh HD volume/partition and format it.

Once there is nothing on the internal drive it should allow you to install macOS and there should be no conflict with the credentials previously used.

If you have not established an AppleID and logged into the App Store before you may need to do this once. It will likely want a payment method (credit card) but downloading and installing macOS is free. You should be able to do this in iTunes on your MacBook Air before you do the whole reformat then reinstall routine.