Our veggie plot was a slope and we had a railway sleeper wall erected to hold it all up level. They're heavy and it was a big job so we got some chaps in. They "planted" some sleepers vertically then laid horizontal sleepers behind them stacking them in alternating layers like bricks to spread the joins.
The weight of the soil behind holds them against the vertical posts. The whole lot was lined with sheets of black plastic to reduce rotting from the damp soil and this also prevents chemicalls from leaching from the sleepers to the soil. Having said that, we get mosses and lichens growing on our sleeper walls so the chemicals can't be that bad after a few years of rain and wind.