The 18th century is the 1700s, and the portable steam locomotive was not invented till around 1790/1800. Before then rails had been laid at coal mines and so on, but the trains either moved by force of gravity, or were pulled by horses (or people).
These were the first railways.
But "steam" railways did not really start till the early 1800s (19th century)
But your question is a bit vague, so difficult to give an exact answer.
Do you mean how did they physically lay the track and build the bridges and tunnels?
Or do you mean how did they build and design the actual trains?
Or do you mean how did the railway companies get formed, and then got permission to actually build the line?
Or do you mean how did they choose the route and survey it?
So to give you an answer you need to define what you want to know a bit clearer, as it is a huge subject.
There is a good history of railways here:
http://en.wikipedia.org/wiki/History_of_rail_t ransport