All that is true, but you can not change that without changing the classes substantially, like having to pick one of three classes in the beginning, and let's say for example if you pick ranged you can't equip melee weapons or raise your athletics, and when you pick cav and you get dehorsed you can't block any more or something like that. Changes of this caliber would be needed to grant infantry the same advantage in their domain (melee) as the other classes have in their own resort against infantry. You get what I mean? In the end, if we don't want to invent a completely abstract game for the sake of balance, we have to deal with what the middle ages left us as a base. And yes, middle ages didn't revolve around balance exactly.
We do have some things we can tweak though that ensure pure melee have a clear advantage similar to what ranged and cav have in their role.
We have ways to make cav vulnerable when they are dehorsed. ATM cav players are protected by their horse because of the anti team wound mechanic that was introduced some time ago. You can't really harm a cav player if he is dehorsed and is near his horse before he gets up. That could be tweaked. Anti cav weapons aren't as good as they used to be, in fact shorter weapons are more effective than pikes/longspears. Even a 1 hander can be better because it deals damage so fast and does good damage. Length is meaningless if they don't deal damage fast enough when we're concerned with fast moving things, and if the damage is too low to dehorse
Damage types and armour - We have cut, pierce and blunt and yet all of them are very similar and ranged have access to both cut and pierce. Ranged could be impacted more when wearing armour with the way it affects their WPF. Heavier armour could be more effective against ranged melee weapons
We have the slot system - if ranged had to use 0 slot weapons you could tweak 0 slots as much as you like to balance them in melee. Weapon weight is a great way to balance - lighter weapons have a much harder time blocking than heavy ones
The more time ranged spend reloading, the more time melee have to play to their strengths - pushing in large numbers. Again something that can be tweaked
Xbows have no real skill point sink and they can be used with low WPF. Skill points in general can be used to tweak the classes - the more points you have to put into cav or PD the fewer points you can put into melee skills
I'm sure if there was an interest in tweaking the role of ranged and cav that could be done without changing a popular game mode. Theres also stuff like ranged ammo amounts, how easy it is to hit targets etc