The past perfect is used to connect or relate one past action to another more recent time or action in the past. This sequential relation is often established between clauses with the past perfect where the past perfect is the first action and the second is expressed in the past simple. It is required when the conjunction used to link the two clauses does not indicate a sequence and the clauses are not in sequential order. There is often a consequence to that relation that is either explicit or implied when this tense is used.
The past perfect and the simple past sequence actions that occurred in the past. The past simple does this by the explicit order of the verbs/ clauses - from earliest to latest.
I got in the car, (and I) drove to the market and (I) bought some bananas.
The parentheses indicate ellipsis, which is optional.
You wouldn’t use the past perfect in a sentence like this, it’s just about sequence of actions and the simple past is used for this purpose.
*I had gotten (or got if your British) in the car, drove to the market and bought some bananas to make banana splits. (incorrect use of the past perfect)
It makes no sense to use the past perfect, when the clauses are already in sequential order - just use the past simple.
Sequencing can be done in that past simple with different conjunctions like before and after - and since they provide sequencing, the clause order can change and the sequence is still clear. I drove to the market after I got in the car. I drove to the market before I bought some bananas.
Some conjunctions are explicit in their sequencing while others are much less indicative of the sequence of actions.
For example, when as a conjunction/ time word, doesn't indicate sequence very well.
I left the market and began the drive home *when my wife called to tell me she also needed ice cream.
At best this sentence (with when) is ambiguous. The sequence is not clear and the sentence could be interpreted to mean that the subject simply left the market just after his wife called, or that he left before she called. But with the conjunctions and, then, and then, before or after, the ambiguity is resolved.
I left the market, (and I) began the drive home and my wife called to tell me she also needed ice cream.
I left the market, (and I) began the drive home before my wife called to tell me she also needed ice cream.
I left the market, (and I) began the drive home after my wife called to tell me she also needed ice cream.
The present simple in joined clauses is about sequence, there’s really no implied consequence and no need for the past perfect.
When is properly used to indicate simultaneous or virtually simultaneous actions (one thing happens immediately after another).
Watch what happens when the clause order is changed.
When my wife called to tell me she also needed ice cream, I left the market and began the drive home. (immediate sequence)
This sentence has clear meaning and clear sequence - it just sequences the actions, and you can’t reverse the order of the clause without creating ambiguity. This a different sequence than in the previous sentences and and when indicates that the second action happened immediately after the first.
Now let’s see what happens with the past perfect.
I had left the market and begun the drive home when my wife called to tell me she also needed ice cream.
The sequence of actions is established by the use of the past perfect and the ambiguity of when does not arise. But it’s about more than sequence. The implied consequence is that the subject had to return to the market for the ice cream, or that they would have bananas and no ice cream. The sequence could be easily established with the simple past but not the implication.
You can change the order of the clauses and still get the same meaning.
When my wife called to tell me she also needed ice cream, I had (already) left the market and begun the drive home.
No problem with sequence and the same implication applies.
You can use the adverb already if you want but the tense implies this meaning anyway, so it is not required. The past perfect sequences without needing to use an explicit order to the clauses because the past perfect is always the first action.
When I arrived everyone had left.
Everyone had left when I arrived.
The meaning of these sentences would change drastically if both clauses were in the past simple. In a structure like this (with when) the past perfect is required for the intended meaning. Without it, and using the present simple, the actions are barely sequenced and indicate practically simultaneous actions and imply a causal relation between the clauses. The order of the clauses does not change the meaning.
When I arrived, everyone left.
Everyone left when I arrived.
But you could also get the same meaning of the past perfect using a different time word without the past perfect.
Everyone left before I arrived.
Before I arrived, everyone left.
I'm not sure that the second sentence here is grammatical. I would accept it but would also leave it to others to argue.
Let’s see what we can observe with another sentence.
He had tried to reach her a few weeks before the wedding.
He tried to reach her a few weeks before the wedding.
In these two the preposition before takes an object not a clause but it still indicate a time relation and sequence - the call happened before the wedding.
A few weeks before she arrived for the wedding, he tried to reach her.
A few weeks before she arrived for the wedding, he had tried to reach her.
He tried to reach her a few weeks before she arrived for the wedding.
He had tried to reach her a few weeks *before *she arrived for the wedding.
In all of these sentences the preposition before (also a conjunction in the last two) takes care of the sequencing so the past perfect is not required in any of them. But it is not ungrammatical to use it if you want, though it makes little difference in the meaning of the sentences. The only difference is that the past perfect implies a consequence in the relation, whether it is expressed or not, and the simple past simply states the fact that these actions happened in sequence.
Hope that helps.