Two past perfect verbs in the same sentence
Solution 1:
As PeterShor's comment indicates, the past perfect shows only that the event referred to occurred before some other event. If (as in your examples) there are two instances, then there were two events, both occurring before something else. As a matter of logic, one of the two events referred to must have happened before the other (the second in your first example and the first in your second), but that has nothing to do with the grammar used.