“Can we stop by an ATM on the way there?”
You're riding in your friend's car on the way to a restaurant where you're meeting a few other people. You don't have any cash, so you want to go to an ATM. You ask your friend who's driving this.
Can we stop by an ATM on the way there?
This means to quickly go to a place before continuing to your final destination.
You usually indicate the destination with "to":
on the way to the airport
But "there" and "here" are exceptions to the rule. They don't use "to":
Was there any traffic on the way here?
When you're talking about going to a place, you usually use the word "to":
I was on my way to work.
We're going to Dallas for Christmas.
The word "there" is different, though. You use it by itself:
I was on my way there.
We're going there for Christmas.
"Here" and "home" work the same way:
I moved here in the early '90s.
We're driving home.