An obsession with protecting the North-West Frontier (now in Pakistan) with Afghanistan from invasion led to the construction of several ‘strategic’ railways, including the Khyber Pass Railway which opened in 1925. They proved to be hopeless commercially and were little used since no invasion attempt was ever made, except by the Japanese from the east in World War Two.
('Railways and the Raj: how the age of steam transformed India', 2017 by Christian Wolmar)
Brits were almost obsessed with the possible invasion of India from Afghanistan. This obsession led to at least one hilarious situation in Maharashtra. Prince Nicholas II of Russia visited India in 1890. A humour writer (Ganesh Kolhatkar) fabricated Nicholas II’s imaginary but lost diary and started publishing the contents from it, stating he was in possession of it. The British did not get the joke and mistook it as real and the writer was interrogated by the senior officials of the Raj!