At its most basic level and without going into legal details -- if a road or public footpath existed before a railway was built, then it had to provide some means for the road / path to get across the railway when it was built. Similarly, they could not block farmers from reaching parts of their farm which might be split into two halves when a railway was built. in some cases, the "means of crossing" might be a bridge, rather than a level crossing.
Of course, variations can be incorporated into the Act of Parliament authorising construction of a railway, and in some cases, a court can authorise the closure (or diversion) of a public highway or footpath.