VS 2022 is needed for the libraries and older versions of VS are needed for older versions of Unreal - it is the easiest way to install everything you need for Unreal development. Installing VS Code is optional and we’ve had many discussions about this. It is a lighter editor and is cross-platform. For the mac C++, you need XCode installed too and for Linux a bunch of different stuff again.
Most importantly here, specific versions of the tools need to be installed, such as for UE5.0 you need .NET Core 3.0 and later versions require 6.0
Honestly, the IDE doesn’t matter too much as long as you have it configured correctly. I personally use Rider but would use Visual Studio over VS Code any day because it is simpler to set up and use.
I have VS 2017, 2019 and 2022 installed to support UE back to 4.24 but use Rider for all my work from UE4.25 or later as it works. I use the same editor for Unity too which is convenient.
Honestly, you could theoretically edit your code in Notepad if you wanted to and it should work.