The past perfect construction is used to show that one event in the past happened before another event in the past. In your first example, the waiting and the rain stopping are both in the past, but the waiting occurred before the stopping of the rain, so the past perfect construction I had waited is appropriate. However, where a word, such as until occurs in the sentence, that is usually enough to show that one action happened before the other, so in most cases it is possible to use the past tense instead of the past perfect construction, allowing I waited until the rain had stopped.
In the second example, once again the staying indoors and the leaving of the soldiers both happened in the past, but the staying indoors happened before the leaving of the soldiers, so there the past perfect construction Villagers had stayed indoors is appropriate. The alternative version also shows that the past tense (Villagers stayed indoors) can be used instead of the past perfect construction where it is already clear that one event occurred before the other. The use of the past perfect construction in the second half of the sentence is optional and makes no difference to our understanding of the sequence of events.
In summary, you can use either the past tense or the past perfect construction in either or both of the main clause and the subordinate clause in each of your examples and the effect will be much the same, particularly as another feature of the sentence make the sequence of events clear. Different people will use different combinations on different occasions, depending on the surrounding context.