A relative pronoun is an inherent part of speech. A direct object complement is a role played in a given sentence. A word can belong to both categories for the same reason a noun can be a subject.
In this sentence, we could say that les souvenirs is the COD of raconte and that que is the COD of a gardés, as well as deriving its meaning from les souvenirs.
Similarly, qui can also be a subject:
Les sénateurs républicains, qui ont presque tous voté pour confirmer le juge, n’étaient pourtant pas unanimes.