Whoever can most cost effectively put explosives on target wins. The future will be annihilation at a distance with cheap standoff weapons followed by swarms of cheap drones loitering over battlefields to clean up.
Due to the nature of their deployment (ad hoc, improvised, crowd-sourced) swarms of quads in Ukraine didn't have much of a counter. Nobody had thought enough about it yet. All the work had gone into developing really sophisticated, cheap drones for consumer use, and strapping a bomb on them was all it took to weaponize that consumer technology. Nobody had spent a similar amount of time developing an equally sophistic…
There are specific 'counters' like pikes, fortifications etc, but they only trade effectively against head on charges. Cavalry still held the advantage of tactical mobility, which meant they dominated reconnaissance, can pursue and annihilate defeated enemies, can retreat gracefully etc.
There may be no counters to drones except for more drones. Or the counter may have to be highly strategical, such as devastating hack-based attacks that may involve use of advanced and dangerous AIs (Cyberpunk Blackwall...).
Artilleries also had no counter for like 50 years. And completely reshaped military doctrine and strategy, made WW1 into a slog etc. WWII found a way to 'beat' artillery by armored thrusts to get behind them, but that is not easily achievable.