"The prerequisites for unreal engine failed to install"

I just had to reinstall windows a few days ago, I installed VS 2022 and it has been working well for me.

Maybe do a full uninstall and re-install. Make sure to include the .NET (c# etc) option and c++. There is also an option to include game support, there is one in that section that includes unreal - make sure that is ticked. With those options it shouldn’t take too much HD space.