Ideally, an army facing off against horse archers would have their own horse archers, which would hopefully eliminate the other side’s advantage. Otherwise there wasn’t really much you could do offensively. Mounted archers would try to deceive opponents and trick them into attacking, which would probably be disastrous for the attackers. But horse archers weren’t invincible, and the best tactic was strict discipline and defense, to avoid falling for their traps.
The advantage of mounted archers was the they were very light and very fast. They had small horses and small composite bows made of wood, horn, and sinew. Infantry and heavier cavalry couldn’t catch up to them. Their tactics involved shoot a lot of arrows in a short period of time, causing fear and disorganization, and pretending to retreat in order to trick an opposing army into chasing after them. This is how they fought for a thousand years, from Central Asia to the Middle East, to Africa and in Europe as well.
In the ancient world the Romans encountered mounted archers in the Middle East, at the Battle of Carrhae for example, in 53 BC. Mounted archer units were added to the Roman army and were used at least up to the 6th century, when they were still being used by the eastern part of the empire. A late Roman military treatise, probably written in the 6th century, discusses tactics for mounted archers:
“An archer using the bow while in motion can fire more accurately if he shoots in directly opposite directions. What I mean is when the pursuer shoots at the one fleeing or the one fleeing at the pursuer, both, of course, shooting from horseback.” (Three Byzantine Military Treatises, pg. 129)
Techniques for loosing an arrow are also discussed - how many fingers to use, where to hold the bow, etc. These tactics were used by Roman horse archers alongside the other usual late-Roman military units - regular heavy cavalry, other archers on foot, and foot soldiers carrying spears/javelins/slings. By then, the eastern part of the Empire (let's just call it Byzantine for convenience) was beginning to encounter nomadic tribes from the central Asian steppes such as the Huns, the Avars, and later the Turks, whose armies were entirely cavalry and sometimes mostly mounted archers. For some reason the Romans/Byzantines stopped using mounted archers in their own army; perhaps a Byzantine military expert might know why better than me, but I’m guessing they started simply hiring Turkic archers and stopped training their own men in these techniques.
Whatever the reason, by the 9th century, emperor Leo VI complained that they had to learn how to defend against horseback archery because all forms of archery, mounted or not, had been completely forgotten by the Byzantine military. Leo focused on training archers, although only on foot, not mounted units. Leo noted that the Turks
“devote a great deal of attention to archery on horseback…they prefer battles fought at long range, ambushes, encircling their adversaries, simulated withdrawals and wheeling about, and scattered formations…when it comes to battle, an infantry force in close formation opposed to their cavalry will inflict the greatest damage on them. They do not dismount from their houses and, since they have grown up riding on horseback, they do not last long on foot.” (Taktika, pg. 455-459)
Tactics for defending against horseback archers involved limiting the distance between them and the Byzantine infantry to reduce their advantages in speed and manoeuverability. Strong discipline was also important. If the infantry could engage with Turkic cavalry at close range, then after bearing the brunt of an archery assault, they could attack with their own javelins and archers as the Turks would be at their most defenseless position in between volleys. Leo also suggested targeting their horses:
“…against the archers themselves, defenseless at the moment of loosing the arrow, and against the horses of their cavalry, the arrows shot by our army are extremely effective and will cause severe harm to the enemy. When the horses so highly prized by them are destroyed by the continuous archery, the result is that the morale of the Saracens, who had been so eager to ride out to battle, is completely beaten down.” (Taktika, pg. 447)
Of course, the success of these tactics depended on the Byzantines being able to surround the cavalry and attack in close quarters. Not so easy when the the Turks’ own tactics focused on attacking from a distance and causing disorder and panic.
At the same time, the Turks of central Asia were also well-known as expert horse archers in the Abbasid caliphate. The 9th-century Abbasid author al-Jahiz described their skills and tactics in his essay “The Virtues of the Turks”:
“The Turk shoots at wild animals and birds, a target on a spear, people, a bird on a pole, and raised images. He shoots while his mount is galloping backwards and forwards, right and left, up and down. He shoots ten arrows before the Khariji [Arab soldiers] can notch a single one. He races his mount down a hill or into a valley bottom faster than a Khariji on level ground. The Turk has four eyes, two in his face and two on the back of his head.” (Hutchins, pg. 195)
The Turks themselves didn’t leave much written evidence of their training and tactics, but there is a much later Mamluk treatise from 14th-century Egypt. By then the Mamluks for the most part probably weren’t Turks anymore, but they still uses mounted archery and their tactics and training were probably similar to their Turkic predecessors:
“Holding the reins with middle finger and ring-finger, the archer should grasp the bow with the whole hand…When charging, he stands in the stirrups and leans forward ever so slightly, taking care not to lean over too far. It is a half, and not a full, standing position that is required as the rider rises in his stirrups…” (Saracen Archery, pg. 73)
In the Muslim world, horse archers sometimes fought against Arab armies, and sometimes opposing armies both had units of mounted Turkic archers who fought against each other. In the 11th century, the Turkic sultan Mahmud of Ghazni wondered how to defend against them too. One of his advisors suggested taking enemy archers prisoner, cutting off their thumbs, and sending them back to the opposing army. Mahmud felt that would be too cruel - but it shows that one army of mounted archers didn’t really have any defense against another similar army. The only way to stop them would be to make it impossible for them to hold a bow.
During the crusades, western European armies encountered Turkic horses archers for the first time. Mounted European knights in Europe were heavily armed and armoured, and they would charge at an organized group of soldiers (cavalry or foot) who would either be broken by the charge, or resist them. They had no tradition of horseback archery but they were accompanied by foot soldiers armed with bows and crossbows as well as spears and pikes. Knights were relatively mobile, at least compared to the archers and other foot soldiers.
But compared to Turkic cavalry, European knights were very slow. There wasn’t really an organized mass of cavalry or foot soldiers for a crusader army to charge at. The lighter and faster Turks were constantly charging at them, loosing their arrows, retreating, regrouping, and repeating. Crusader archers on foot could shoot at them, as long as the Turks stopped in one place, but they usually didn’t - as the Byzantines had learned, drawing Turkic cavalry into close-quarter combat reduced their advantages in speed but crusader armies weren’t fast enough for that.
At a distance, accuracy wasn’t too important, and their arrows may not even have been lethal. At least among the heavily-armoured crusader knights, arrows might not be lethal, but could get stuck in their armour instead. Some crusaders noted with amusement in hindsight that they looked like a hedgehog with its spikes sticking out, but in the heat of battle it was probably terrifying, never knowing whether the next arrow would pierce the armour or not. And just as the Byzantines had discovered the effectiveness of targeting Turkic horses, the Turks did the same to crusader knights whenever they could:
“The tactical use made of this archery was to destroy the cohesion of the enemy, and this could be achieved by inflicting upon him the loss not only of men, but of horses…The Franks relied for victory in battle on the mounted charge, and the Turks were well aware of the value of destroying their horses.” (Smail, pg. 81)