The phenomenon you describe may be (adjacent) metathesis, which is not infrequent in phonology. Metathesis means "swapping". In linguistics, adjacent or local metathesis refers to the swapping of two adjacent sounds at some point in phonological developments. As to why it happens, I know of no formal explanation.
Apparently, there is something in our brains or speech apparatus that makes certain sounds less "easy" or pleasant to pronounce in combination with other forms as part of a phonological system (a language), or less easy to remember subconsciously. We are then inclined to various degrees to change pronunciation in a way that renders it closer to our common speech patterns.
A sound can simply be changed, as in the change from older English -th to modern -s in makes; alternatively, adjacent sounds can be swapped, as in iron, which apparently evolved from /(a)irən/ into /aɪə(r)n/ in modern pronunciation: the r and the schwa were swapped.
It can be seen that this is in certain circumstances a natural inclination in us humans by the frequency with which (non-Italian) children pronounce spaghetti as pasghetti; the cause is that sp- is natively infrequent in many languages, such as English and Dutch. Languages tend to sometimes transform borrowed foreign words to conform to native phonology (sound patterns).
In the case of quartus, -t- is an adjectival suffix. It is possible that at some point a form **kwat(w)rtos* existed in Proto-Latin. If so, dissimilation may have been the main cause of the metathesis: a t sound twice, especially combined with a w sound twice, tends to disappear or transform in Latin, as in many other languages.
Alternatively, it may just be that the consonant cluster **-t(w)rt-* was too "difficult" to pronounce, i.e. not conforming to Latin phonology, and hence transformed/simplified into -rt-. But I do not know the intermediate stages.