For there is be a model there has to be an original. Railways have been around for several centuries, there is evidence that wagonways where in Greece as early at 600 BC and certainly in Britain as early as the 1600s. The first steam railway as a goods line was the Stockton and Darlington in 1825 followed by the first passenger railway the Liverpool and Manchester in 1829. By 1840 Railways where a familiar sight through most of Britain.
It is highly likely that between 600BC and 1825 that there would have been quite a number of carpenters living near to wagon ways that took a block of wood added wheels then joined 2 or more of these together for their children. However that aside model railway proper started with carpet trains around 1840 called Birmingham Dribblers, basicly a steam boiler, but it was not until the late part of that century that movement in the form of clockwork and later electric motors made things more proctical.
A Birmingham Dribbler one of the first Model Trains