Suburban railways in megacities exert a pivotal role in propelling urbanization and shaping urban agglomeration. However, previous study endeavors have overlooked the transformations occurring in urban expansion along suburban railways, with a particular dearth of attention on the spatio-temporal evolution of landscape ecology and urban function. Therefore, this study employs the megacity of Beijing as an example. It utilizes remote sensing and point-of-interest (POI) data spanning from 2008 to 2022 to construct an indicator system from two essential dimensions: urban form and function. We explored the spatio-temporal characteristics of alterations in urban expansion within the gradient buffer zone adjacent to the suburban railway network in Beijing. The results showed that: (1) The rates of urban expansion were highest in 2008–2013 and lowest in 2013–2018; moreover, suburban railways had the greatest impact on the built-up area within 2–4 km along the route, and the impact gradually decreased beyond 4 km. (2) The direction of urban expansion shifted northward in the direction of latitude and eastward in the direction of longitude from 2008 to 2022, with the shift in latitude being more distinct. (3) The number of urban functions gradually increased from 2008 to 2018, but the number of medical services suddenly increased and the number of other urban functions decreased from 2018 to 2022; in addition, urban functions other than scenic spots were mainly distributed in the main urban areas, with very few clusters distributed near stations. (4) The landscape shape index became more irregular and fragmented from the center along the route to the edge of the buffer zone from 2008 to 2013, and the degree of fragmentation was highest in the 2–4 km buffer zone. In summary, this paper analyzes the spatio-temporal characteristics of urban expansion along suburban railways through four indexes, namely expansion rate, expansion direction, urban function, and landscape shape, and the results of this study are of great significance to the development and planning of suburban railways in megacities.