So We had a country A, B, and C here. A want B to be under their influence instead of C. One of the method they can do is offer to build a railway to connect their country to promote "close cooperation" under the guise of business.
Once the railway is completed, country B will found it's economy relying a lot on A. Country A can use this dependency as leverage when they want country B to do something for them like go to War with C or create policies that will benefit country A more.
Should Country B refused to cooperate with Country A request, Country A army will be able to seize Country B faster than Country C because of the railway they build between their country.
Some of the best example we can see in the past on how train help certain country become powerful is during the British Empire and the Japan Meiji Restoration.
For the British Empire, I will use my country as an example.
The Kuala Lumpur railway station is built by the British in 1910. it remains an important hub even during modern times. It not only brings development to the land around the station. It also allows the British troop to suppress any rebellion faster.
During WW1, railway plays a huge role in the war because it allows the defender to bring their reinforcement faster to the frontline. It forces the attacker to capture railway if they wish to advance any further into the defender land. It is an advantage for the defender if you know where the attacker need to attack. The defender just needs to have all their troop secure the railway station and wait for the attacker to come to them.
When the Japanese invade Malaya, most of their navy is at the South China Sea. I believe if that wasn't a railway on the west coast, they would have focus on east coast first only then go west. However, because of the railway, they need to secure all the railway stations on the west coast to secure their flank before they can advance to Singapore.
One of the tactics a defender will use is using a different Track gauge size. This is to make it hard for the attacker to use it if they attempt to connect the defender railway to their own railway. The attacker will found their advance slow down due to their supply unable to reach them. While it is possible to use a truck to bring supply, but they can't carry as much as a train.
During WW2 when the Russian invade Hungary, their army had to slow down due to supply unable to catch up. It is due to their train using different track gauge sizes.
This is why you don't see many railways that connect many countries at a line because of how powerful it is as a tool during peace and wartime.
such a railway only exists only both countries want to build a strong alliance.