You do not really need to root your device, but this app must be placed in /system/priv-app/ or /system/app/ for old OSes. It can be easily achieved by using a third party recovery. You can also use root explorer or some other file managers to move this app into the required folder on a rooted device. Otherwise it won't work.
So for your convenience, the APK can be directly downloaded at https://github.com/Hzj-jie/android-mobile-network-mode/raw/master/android-mobile-network-mode-release.apk.
This app installs three items in app menu, "Enable 2G", "Enable 3G" and "Enable 4G". Each one does its job and quit. i.e. Enable 2G, 3G or 4G. Please refer to the first screenshot.
I am using this with https://play.google.com/store/apps/details?id=org.gemini.init, and change network preference according to the location. Ex.
You can also manually set the the preferred network type by using an intent,
The type can be found in https://android.googlesource.com/platform/frameworks/base/+/master/telephony/java/com/android/internal/telephony/RILConstants.java#136.