You can ask "Can I help you?" if you want to offer someone help.
But this is also the phrase that employees of a store or business use to greet customers or visitors. When a visitor seems lost or confused, the employee asks:
Can I help you?
Sometimes "Can I help you?" can be pretty negative. It can mean "You're not one of us." You can use it when someone is in a place that they don't belong in. For example, if there's a man that you've never seen before walking back and forth in front of your house, you can open your door and ask them:
Excuse me, sir. Can I help you?