Archers typically carried sidearms - commonly swords, but sometimes other weapons, too. In the early Medieval period, when swords were relatively more expensive, many archers would have carried something other than a sword: perhaps an axe, or a large knife, or a mace/club. In the later Medieval period, the sword was a very common sidearm for archers.
For example, contemporary descriptions of the Battle of Agincourt (where most of the English army was archers) note their sidearms: "having axes or swords hanging from their belts", "swords, hatchets, mallets, axes, falcon beaks and other weapons".
For mounted archers, the bow was not always their main weapon. For example, their primary role might be to fight in close combat as armoured lancers:
https://commons.wikimedia.org/wiki/File:Taq-e_Bostan_-_equestrian_statue.jpg
https://commons.wikimedia.org/wiki/File:Ardachir_relief_Firuzabad_1.jpg
https://commons.wikimedia.org/wiki/File:Tabriz_Sasanian_Plate_3.jpg
While their bows are not visible in these artworks (because they would have worn their bow-cases on their left side), their quivers are visible (worn on the right side). While their primary weapons are lances, they are also carrying swords. Armoured cavalry were often aristocratic warriors, and could afford swords even if they were very expensive. Other horse archers were much less wealthy, and might carry clubs or maces as minimal sidearms instead of a sword.
Cavalry sometimes carried multiple sidearms, such as an axe or mace in addition to a sword (in addition to a lance and/or bow). Infantry usually worked harder to reduce their carried load, and were less likely to carry multiple sidearms like these.
Cavalry might also carry other ranged weapons in addition to their bow. For example, they might carry a musket:
or some javelins.
When cavalry shifted to firearms as their main weapons, they still usually carried swords as sidearms (into the 20th century, when magazine-fed carbines were available).
For more on European archers' sidearms, see my past answer in
For more of the same, and also considering East Asian archers and mounted archers, see