How to define a preferred Mobile Network?
TL;DR: you cannot do that, at least not without root.

Now the reason for this is due to security concerns there are not public APIs to actually do that software-wise. The closest you can get without root is using this software: https://play.google.com/store/apps/details?id=com.kmshack.autoset but it can toggle almost anything (after providing adb permissions) besides the network operator, again due to security reasons.

The preferred network list is defined by the operator (see Preferred Roaming List) so you cannot really influence it. You can however enable/disable network roaming in the menu or alternatively if you have root do it programmatically with xposed: http://repo.xposed.info/module/net.caze.roamingcontrol. You can also use the hidden android menu *#*#4636#*#* where you can control how your phone will determine which network type (not operator type) to prefer, still this is in regards to the networks in the preferred list set by the operator.

You still have the option to ask your operator to disable roaming for you, which might be a solution, however that would really require you to ask them to enable it again if you travel elsewhere ... 

And finally you can try the macro route via this: https://play.google.com/store/apps/details?id=com.joaomgcd.autoinput