Along is used to express someone or something moving in a constant direction from one part of a (typically horizontal) surface to another. Many sources state that the surface in question needs to be long, but that is not always the case. Certainly, when we use along, we often do so to refer to something lengthy like a road or pavement; but even if you were to simply run your hand from the top of your arm to the tips of your fingers, you could accurately say that you ran your hand along your arm as you moved it from one end to the other.
Essentially, along in this context is used when we want to say that someone or something is moving in or on a line, and the line in question is not limited by size (nor does it need to be straight).
In this picture, we can say that the boat is moving along the river as it is moving in a constant direction from one part of the river to another. Alternatively, we can view the river as a line with the boat following its direction:
“We ran along the beach.”
“She walked along the avenue to the house.”
“I looked along the shelves in the library for the book I needed.”
Along can refer to someone or something extending to the side of a surface in a line matching its length and direction, or - in other words - in a line next to something.
“There were a line of trees along the side of the road.”
“There were houses along both sides of the train tracks.”
“Fans were lined along the route to cheer on the cyclists.”
To help you get a better idea of these two usage rules for along, look at this picture:
Here, it would be accurate to say that the trees are positioned along the road, and the car is moving along the road.
Along can also be used to describe someone or something at a specific point or location on or beside a surface. In this context, it is often used in relation to direction.
“The doctor’s office is along the corridor to your right.”
“The shed is along the back of the house.”
“To get to my house, drive along Main Street and turn left at the traffic light.”