It happens quite often by geocaching: the cache is situated somewhere near the rail track, but it seems that you are on the wrong site... The legal passage is quite far, and you have still a lot of caches to get... and don't want to loose too much of it just going there and back.
Yes, many German cache descriptions contains information that you shall not pass, at least not the rails in every place you'd like to. Of course, I'm not not talking about going through rails when the policeman is in sight, neither of rails with 'third rail'. I'm talking about just normal, not heavily used rail in not heavily trafficed place.
How the situation looks like in Germany? What's the pessimistic scenario that I should count with? Let's say someone sees me crossing rails in camera, or some rail worker will be incidentally somewhere near... Would someone care to catch me or to call a police for something, that in Poland is too trivial to even deal with it?