5UD715 Said:
"Annoying Headache, macOS Problem: i corrupted or deleted some system macOS files mistakenly now unable to boot into existing OS nor New OS installation completing Properly giving error in last saying 'an error occurred while installing macOS, try running this application again'"
-------
Troubleshooting macOS System Files:
A. Reinstall the macOS:
Nothing would be deleted. It's just that items that have become corrupted or deleted, would be replaced or reinstalled back to where they should be. Go Here: How to reinstall macOS from macOS Recovery - Apple Support.
B. Important: (applies if you can log in) Be certain to create a backup of your Mac prior to all of this. That way, you can have something to restore from the Mac from, should anything go wrong with the reinstall. Once reinstalled, try this once more, seeing if you still get this error.