The nature of a Tank
I'm going to answer your questions in reverse - focussing on the Tank element, because I think that will help you understand the meta-answer. Currently, there is a lot of talk by some people in regards to a certain current conflict where one side has taken a significant number of Tank losses due to Man portable AT Rockets (N-Law, Javelin etc.).
The current talk is 'The tank is dead!' - this generates the counterpoint (which is why I raise it) - which is what a Tank does for a Military is not 'being a tank'.
What a Tank does is be
- Mobile
- Protected
- Firepower
Mobile - it can go other places relatively quickly, with tracks it can go places wheeled vehicles cannot.
Protected - It can stop small arms fire, stop certain types of Armour Piercing rounds etc. The best example of this in the modern era (not including Ukraine...) - is the Challenger 2 used by the British Army face-tanking (heh...) something like 70 RPG rockets and survived.
Firepower - Tanks have a pretty big gun. Not the biggest on the Battlefield - but a 120mm shell is a damn good way to get someones attention. Not to mention Pintle/cuppola mounts for various types of Machine Gun.
'That's all very nice - it doesn't answer my question!' - Hold your Horses....
Speaking of Horses, there's a reason why in the US, Tankers are part of the Cavalry units - because historically - Mobile, Protected Firepower was the role of your heavy Cavalry.
My point is therefore: An Army will always require Something that is more Mobile than a Human (even one in super powered armour), More protected than a Human (ditto) and able to carry a bigger gun than a human (again...)
This is the 'role' of a Tank.
Think about your scenario - what sort of Mobility do you need, what degree of protection do you need and what sort of Firepower do you need?
For swarm-type enemies - Higher Mobility, lower Armour and Area-of-effect Weaponary (Flame tanks) would be what was needed. Fast enough to get out of trouble, lightly armoured because a single swarming enemy isn't an issue, but getting caught but 1,000 of them because you were too heavy to evade is and issue. And Weaponary is pretty self-explanatory.
For a Titan-type enemy - I'd look to something like the Swedish S-Tank - very low visibility, with a very sloped front glacis and a big gun. An Ambush predator - Hide from the Titan, unleash several rounds in quick succession, then scoot.
Taking those together - Mobility and Firepower is going to be the biggest aspects that the tank designers are going to spec into. Possibly using a common-chassis design and being able to quickly (1-2 hours) swap out turrets depending on the threat, or possibly using something like the BMP-2 (where there was a 105mm cannon and a 30mm cannon mounted together - one for 'hard' targets like other tanks, the other for 'soft' targets like bunkers and infanry)
The same applies to your infantry
That is - you want them protected enough that they can survive and have a weapons loadout that is mixed enough to deal with the majority threat they are likely to face, but with enough bang to give an unexpected adversary a bloody-nose before retreating.
e.g. a Swarm-killing squad would still have a couple of man-portable Anti-Titan weapons and a couple of other heavy weapons - so if they encounter one, they can give it something to think about whilst they retreat/call in the specialist support units. and Vice Versa.