Train surfing is illegal on most railways in the world, with some exceptions. Many railroad companies usually take a zero tolerance policy to practice of riding on exterior parts of trains, and employ railway police and guards in an attempt to prevent the practice.
Depends on the railroad. Many railroads now prohibit getting on and off moving trains. Where it is permitted, there's a very specific way to do it safely which is actually counterintuitive. You get on and off with the TRAILING foot, not the leading foot.
Train tracks are private property. Walking, biking, jogging and standing on or next to them is considered trespassing. With court and penalty assessments, a first-time offender may have to pay nearly $400. You Might Not Hear the Train Coming.
As far as I'm aware, there's no legal limit. Passenger trains do not normally exceed 12 cars (around 900 feet, dependent on rolling stock type), but many are much shorter than this.
Walking on or beside railroad tracks is illegal. The only safe place to cross tracks is at designated public crossings with a crossbuck, flashing red lights or a gate. Crossing anywhere else is illegal.