Since "caballo" means "horse" and a "caballero" is a gentleman, is the origin of the word that the "lords" rode (whereas the common rabble walked)?
cowboy is a
vaquero, the one that leads the cattle.
Caballero has nowadays the meaning of "gentleman", and the word comes from "horse" but actually not the horses used to ride (equus –i), but the ones used for the hard work (caballus –i).
Caballero, del latín caballarĭus, es una persona que va a caballo o que cabalga. Dado que, en la antigüedad, la persona que montaba a caballo pertenecía a una cierta clase social, el concepto adquirió diversas connotaciones y significados.
Caballus venía a su vez del griego kaballes –ou, con el significado igualmente de caballo de trabajo. El guerrero era un hombre noble que había servido como paje y escudero. La palabra Knight (caballero en inglés) deriva de la palabra anglosajona Cnight, que significa sirviente.
The key is on the first quote, that explains how the word acquired, by association, certain connotations and thus its actual meaning.
I think the historical context you're missing is that "caballero" is similar in spirit to the french "chevalier" which implies horse as well (cheval in french) but really means knight. So you can think of caballero as gentleman in a modern context, but historically refers to knights.
Actually it does. In the medieval era it was common for nobles (including knights) had access to the best education available, which meant they had better manners than commoners.