When you install the Unreal Engine via the Epic Games Launcher you are able to configure the components that are installed, such as support for Hololens or Android.
What would be the equivalent of this when building the engine from source? Is there a way to configure the build so that unneeded components are not included?
You need to make an Unreal Installed build with BuildGraph.
After you have configure all your dependences for all the platforms you want, you open a cmd terminal in windows and go to the root of you unreal source and write down the following:
Engine\Build\BatchFiles\RunUAT.bat BuildGraph -target=“Make Installed Build Win64” -script=Engine/Build/InstalledEngineBuild.xml -clean -set:HostPlatformOnly=true -set:WithLinux=true -set:WithLinuxArm64=true -set:WithAndroid=true -set:WithIOS=true -set:WithHoloLens=true -set:BuiltDirectory=“C:/UE5.2/”
-target= is the platform you want to run your Editor in my case Windows.
script= is the script you going to use to make the buildgraph. you can make your own but is more easy to use the one epic provide us 
-clean= going to delete everything each time you start the build.
-set:HostPlatformOnly is going to build the Editor only for Windows.
the rest is self explanatory. if you want to be able to compile your game for IOS for example ,you use -set:WithIOS=true.
Inside the InstalledEngineBuild.xml file are all the switches you can use with description you can check it.
-set:BuiltDirectory=“C:/UE5.2/”: is the folder where the final product will be copied once it finish all.
And let me tell you is a long process.
that’s all the platform I build and it take 7 hours with a Dual Xeon with 28 Cores and 56 threads.
Good luck.