There are four factors that potentially impede railroad through-running. The most well-known is track gauge: the physical distance between the rails. The standard standard track gauge is 4'8½" (1435mm), which holds for most Western countries and China. Former Russian Empire countries use 5' (1520/1524mm) gauge. Ireland, India, Portugal, and Spain use even broader gauges (5'3"-5'6"). Narrower gauges (meter gauge and 3'6" gauge) are common in Africa and Japan. Although I should note that I think every HSR system (even in those countries with different standard gauges) has settled on 1435mm gauge.

Less well-known but equally important is loading gauge: the physical envelope through which a freight railroad car must fit. The US (& Canada & Mexico) rely on a wider loading gauge than most of Europe, but have also increasingly standardized on a much taller loading gauge to fit double-stacked container traffic [1]. Europe varies widely, from the tiniest loading gauges in the UK to the roomiest in Sweden (roomier, at least in width, even than the US).

More minor features are the electrification standards (which only matter if you're running electric trains), which side of two track systems you drive on (not necessarily the same as the road network in the country!), the signalling system (especially if the trains have positive train control).

But enough about railroads, how about connecting the world by rail? There are presently 7 major railroad "islands" (ignoring gauge issues) as well as a buttload of ones too small to be worth considering. These are the US/Canada/Mexico system, Eurasia, southern South America, India, Thailand/Malaysia, Australia, and Japan. What does it take to connect these?

Going north from South America, you have to either cross the Amazon rainforest or trace your way up the Andes mountain or coast route. Both of these are technologically possible, but are likely economically prohibitive. The Darien Gap between Colombia and Panama remains a gap largely because there is a conscious political decision not to close it. Heading north through Central America, you again have to build a lot of greenfield track in mountainous jungle terrain, which is technologically feasible but again economically prohibitive. It's not until Mexico that you pick up existing track.

Continuing our proposed circumnavigation, we run out of track in northern British Columbia (or Alberta). So there's more greenfield track needed to reach the railhead of the Alaska Railroad. There's apparently a project started up (again) to make a connection between Alaska and Alberta, but I'm not holding my breath on it actually happening. The Alaska Railroad only barely helps you move towards Russia--it turns south at Fairbanks, and now you need 2500mi (as the crow flies!) of greenfield track to get to the Bering Strait, cross it, and then get to the Russian railhead at Yakutsk. It's not clear how technologically feasible a Bering Strait crossing is; while the water isn't particularly deep, it's a long crossing (>50 mi), and the icing over of the seas presents some structural issues for bridge supports.

India is islanded from Eurasian rail network principally because of political disputes with some of its neighbors and the same mountainous and/or jungle terrain issues with the others. Connecting Japan to Eurasia is pretty easy via Sakhalin (the underwater tunnel would be no more difficult than the Channel Tunnel), although Sakhalin is sufficiently roundabout that it's of questionable utility. More interesting is a Korea/Japanese link that is again of questionable technological feasibility.

Africa's islands are a combination of neighbors hating each others' guts, overall poor infrastructure generally, political instability in several regions, terrain issues (particularly in central Africa), and severe track gauge mismatch issues. There's no technological issues towards connecting everything together, although Madagascar I believe is firmly in the realm of not feasible to construct any sort of crossing to.

Connecting Australia produces an interesting result. The Torres Strait (between Australia and Papua New Guinea) is actually pretty easy to cross--think something like the Florida Overseas Railroad. But actually hooking the Indonesian islands all together is challenging. Sumatra and Java would be pretty easy to link up to Malaysia. But as you head further east along the island chain, you discover nasty deep oceanic trenches that prohibit tunnels and are too far to bridge. Borneo and Sulawesi will forever remain islands, although maybe reach the Philippines from Borneo is possible.

[1] The standard well car can carry 2 containers for a total of 4 TEU--the standard "long" container you see is actually 2 TEU containers, not one.