Rail network size is usually measured by total route length, so we can compare the four countries on that basis.
India: India runs one of the largest rail systems by passenger volume, and its network is large, but its total track length is smaller than a couple of other countries on this list.
China: China has expanded its rail system fast, especially high-speed lines, yet its total network length still trails the country with the biggest overall route length.
U.S.A: The United States has an enormous freight rail system spread across the country, giving it the largest total rail network length in the world.
U.K.: The United Kingdom's rail network is well developed but covers a much smaller country, so its total length is far behind the top three.
Measured by total length, the U.S.A comes out ahead of India, China and the U.K.
Let's summarize:
A large country size plus a dense freight network gives the U.S.A the longest total rail network.