The crucial thing here is 'case', a concept used to a greater extent in Latin, German, Russian or Arabic, but only shows up in French on a few pronouns. This concept refers to the role of a noun in a sentence. Just like il has the counterparts le, en and lui, so we can say qui has the counterparts que, dont and then a load of preposition + lequel formulas. Indeed in some languages, they list this group as a declension of one word (normally starting with the equivalent of qui).
It's a case of choosing the right one, according to its role in the sentence. Don't forget that this series is officially called relative pronouns and that they are all therefore essentially nouns that represent something in a phrase (which is joined to an earlier phrase). If you want to make it easier, cut the second phrase off just before the qui/que/dont/auquel... and ask yourself what it represents.
qu'on avait volé : well, on is already the doer, the thief, so the car, the thing stolen, the accusative is represented by que.
qui avait été volée : by chosing a passive, you risk getting confused, as it involves putting a logical object (the thing stolen) as the grammatical subject (the thing doing a verb), but because here the car commands the verb it becomes qui.
qui porte une plaque marocaine : is easier, because the car is obviously the doer, the carrier so takes qui (just as you could replace it with il/elle).
dont les vitres sont cassées : here dont replaces de la voiture.
à laquelle il avait dédié sa vie : we're now going further down the series into the prepositional options, but same again, à laquelle represents à la voiture.