Portuguese and Spanish tracks have a smaller width than the rest of Europe.
So Portuguese trains only travel to Spain (the few that exist). And Spanish trains have a system where they can change the width between the wheels when going to France.
Similarly, trains travelling between Belgium and Germany, if I am not mistaken, have dual electricity system.
There are different allowed widths and heights ("loading gauge") for train cars in different countries. Finally, few people know that the overhead lines veer a little bit to the left and right to spread the wear on the pantographs. The extent to which this happens also differs between countries, and some countries have narrower pantographs than others, which means that trains cannot just ride both in Germany and Switzerland even though they have the same electrical system.
I would expect there to be a few real experts on HN, though. (I'm not one.)