I think that the best way to understand this question is through two examples:
1) Les enfants ont perdu leurs jouets.
2) Les jouets qu'ils ont perdus étaient des cadeaux de Noël.
Why in the second example does "perdu" (past participle) agree with "Les jouets" (direct object) but does not in the first example?
One of the key grammatical rules that is learnt in French is that the past participle never agrees when it is preceded by the auxiliary verb avoir. But this rule only applies if the direct object (C.O.D. in French) follows the past participle. This is what the first example illustrates. But if the direct object precedes the past participle, then there must be agreement between the past participle and the direct object.
To sum up, the agreement between the past participle and the direct object is dependent on the position of the direct object in the sentence. If the direct object follows the past participle, there is no agreement. If the direct object precedes the past participle, the past participle agrees with the direct object.