If someone looks lost, ask them if they need directions, or maybe help finding where they're looking for.
A few ways to tell if someone might be lost or need help finding something:
Repeatedly looking around, especially scanning things like street signs, buildings, and landmarks in the area, especially if they're repeatedly looking down at a phone or map while doing this.
Stopping and starting repeatedly, and especially changing the direction they're walking multiple times. You may see them start walking one direction for a while, stop, look around, and change direction. This can suggest uncertainty in which direction to go.
Studying a phone or map intensely for an extended period of time while looking around them.
Looking anxious or flustered, which although this can indicate a number of things, when paired with the above behaviors is more likely to indicate that they're lost and need help finding somewhere.
And finally, if you do see them approach someone else for directions but whoever they approached was unable to help them.
A simple "excuse me, do you need help finding something?" can go a long way. If they refuse your help, don't push it. Respect their boundaries, you are a stranger approaching them after all.
Being lost, especially in an unfamiliar place, can be quite stressful or scary even. Your offer of help can bring much needed relief and reassurance.
Helping others when they're lost encourages a culture of kindness. Small gestures like this contribute to a kinder society at large. When you foster goodwill and community, it can come back around to benefit you.
Not to mention that it's a simple way to demonstrate hospitality to someone either visiting or new to your area. If you reach out and help someone when they're lost, this leaves the lasting impression that people from your city / region / country are helpful and kind.