Line of sight is defined as an imaginary line joining an object and an observer’s eye. When we observe nearby stationary objects such as trees, houses, etc. while sitting in a moving train, they appear to move rapidly in the opposite direction because the line of sight changes very rapidly.
On the other hand, distant objects such as trees, stars, etc. appear stationary because of the large distance. As a result, the line of sight does not change its direction rapidly.