Originally, quam was the relative adverb to tam. Both were used in order to demonstrate that two people or things were equal in some way. "She is as (tam)good at Latin as (quam) he is." "He is as (tam) slow as (quam) a turtle." Later, the Romans would employ this construction, which illustrated equalities between two words, to show inequalities between two terms. It isn't a quantum leap to move from "he is as smart as me" to "he is smarter than me."