There are two separate themes emerging here.
train crews
To answer the original theme, I am not aware of any hard and fast rules. In Europe there are certainly very few instances where trains crews would be absolutely banned from crossing the frontier into another country. Even when the iron curtain was in place, train drivers crossed physical borders, but there is an important element to remember here and that is the difference between the physical border (“line in the sand”) between two countries, and the railway border, whereby there is either one station in one of the two countries, where all changeovers take place or a border station in each country either side of the physical border.
Traditionally, locomotive hauled trains more often than not changed locomotives at these border stations, so the crews would naturally change. However not many of these border station are exactly on the border line, so in most cases the railway administration from one country operated the line across the border as far as the first station in the neighbouring country so train crews travel in ‘foreign’ territory for some distance. These distances can be quite long, for example French railways run as far as Geneva Cornavin in Switzerland, and the SNCF-operated route runs through 15 km of Swiss territory.
Modane (France – Italy). SNCF loco and driver arrive from France at Modane which is 12km inside France but is the meeting point of French and Italian railway administrations. At Modane, an Italian loco with Italian crew take over the train.
Nowadays this is increasingly changing as locomotives and high speed train sets become increasingly interoperable. Nevertheless, in many cases the even where the loco stays the same, the crew is often changed. However as has already been said with reference to Thalys and Eurostar there are some services that now cross borders non-stop. As I understand it the DB and TGV trains on the East Europeen high speed line (Paris – Frankfurt etc) run with mixed crews.
Corridor lines
The second theme is that of ‘corridor’ lines. This was started with the mention of a line in Lithuania/Latvia, but this type of line exists/has existed all over the world. In Europe there are lots of examples, because wars and treaties down the ages have changed borders.
Examples of lines I know well (not all are still open to passengers) are:
Medyka – Kroscienko* (Polish train running through Ukraine – was all in Poland when the railways was built.
Gorlitz – Zittau* (German train running through Poland – was all in Germany when the railway was built)
Liberec – Varnsdorf (Czech train running through Germany)
Garmisch – Kempten (German train running through Austria)
Schaffhausen (Switzerland) area. Particularly complex area where on one line German trains run through Switzerland and on another route Swiss trains run through a bit of Germany.
Wiener Neustadt – Oberpullendorf (Austrian trains ruining through Hungary – was all on e country when the railways were built but later became an iron curtain border.
Even these lies are of two types, either closed trains and no stations (as was the case during the communist era on iron curtain borders, or open trains and stations where both countries are ‘open’ (eg Schaffhausen above).
A superb web site covering all this is Bueker:
http://www.bueker.net/trainspotting/
.