The tactics, competence of leadership and the training and experience of the troops can often be more important than the equipment type alone.
To illustrate it, I present an extreme real historical example of a tercio being defeated by a frontal assault of light cavalry. (the tercio was the successor of the pike square, equipped with musketeers to give it ranged capability, and it was the most successful formation of the battlefields until muskets became advanced enough in the 18th century to make pikes obsolete)
A tercio would normally be easily capable of defeating a heavy cavalry assault even when being outnumbered by them. How could it then be defeated by an assault of light cavalry, where the cavalry had numbers approximately four times smaller than them?
Here is what happened: In 1631 in the Principality of Transylvania, Apafi was elected Prince, but the previous Prince, Kemény, didn't acknowledge the results, which led to a brief civil war.
Apafi, heavily outnumbered, barricaded himself in a city, and Kemény proceeded to besiege him. Before the siege could have been started, an army composed of light cavalry came out of the city (why Apafi's infantry didn't participate, is an interesting story in itself, but would be off topic here).
The besiegers didn't take them seriously ("what could such a small band of light cavalry do against proper tercio infantry?"), and thought they were only out for harassing them, a tactic not uncommon for light cavalry. They expected they will exchange some fire with each other from afar and then retreat (the whole thing being done only to slow down the perparation of the siege), as was common for that troop type, so they sent their musketeers forward. The light cavalry started to get closer. The musketeers fired from afar, obviously causing next to no damage, expecting the light cavalry to be skirmishers and doing the same. However, this is when the light cavalry rushed them without firing a single shot. Surprised, and not having enough time to reload, the musketeers ran back, and got intermingled with their own pikemen when the horsemen crashed into them. The pikemen couldn't hold the line due to the swarm of their own musketeers fleeing through their ranks, and they broke. Thus, most of the army started routing, and in such a case, troops standing in the back don't see what's happening in the front, don't see that they alone would be enough to win the battle, they only see their own comrades panicking, throwing away their weapons and fleeing, so they join the rout instead of staying there.
Kemény's heavy cavalry was nearby and tried to intervene, but couldn't reach the position, having to plow through their own fleeing infantry. Some of them got stuck in them, others trampled down their own infantry, and that situation was no longer salvageable, the army routed from a force less then one fourth its size.
This example was meant to illustrate, that there are situations, where even an army which would otherwise be "invincible" against its opponent, can lose due to incompetent leadership, a surprise attack, or just a combination of good timing and good luck from their opponent's perspective.