The trick, as always, is not to send your tanks charging in on their own, and nor do you generally want your infantry facing tanks on their own . That’s why you’ll hear the term “combined arms” thrown around a lot when you’re reading up on US military stuff.
Basically the idea is that the infantry and tanks mutually support each other, and the supporting branches support them as well (artillery, air). So in theory, the enemy infantry with the Javelin missiles or whatever never get close enough to actually be much of a threat.
But the Russians apparently suck pretty hard at soldiering, so their tanks/vehicles don’t seem to be well supported by infantry, so they’re getting chewed up. Which is exactly what happens to tanks when that happens, even in WWII.
Practically speaking, anti-tank missiles aren’t anything new- they’ve fired big tank-busters from airplanes, helicopters and larger tripods/vehicles for decades now. The only real innovation in the NLAW and Javelin missiles in use in Ukraine is the fire-and-forget guidance- the infantryman can fire it, and then scurry off into better cover. Prior to that, they had to keep the sight on the tank until the missile hit, which left them vulnerable for a while.
You can think of it as a pendulum that swings between the tanks being ascendant, and the anti-tank systems being ascendant. During the first half of WWII, the pendulum had swung toward the tank, as infantry generally didn’t have much to counter them with, and countermeasures were limited to other tanks or relatively heavy anti-tank guns. Then the shaped charge came into its own, with the Bazooka, Panzerfaust, PIAT, etc… for infantry. Tanks and anti-tank guns then also got various other improved ammunition- HEAT rounds (shaped charge), APCR (armor-piercing composite rigid), APDS (armor piercing discarding sabot) that swung the pendulum back toward the center. Not until the 1960s and 1970s did the pendulum swing away from the tank with the development of the anti-tank guided missile, which married a large shaped charge with a long range and a guidance system. Even at that, improvements in engines and suspensions meant that tanks could carry more armor and be faster than before, making them more survivable than before, and damping that swing.
Eventually the pendulum swung the other way in the late 1970s/early 1980s with the development of various sorts of composite armor and of explosive reactive armor. The former is armor made of various sorts of ceramics and metals that is considerably more effective than an equal thickness of armor steel vs. shaped charges and APFSDS kinetic rounds. Explosive reactive armor is different- basically when a shaped charge jet hits the reactive armor, it explodes, disrupting the jet, thus minimizing penetration. It also tends to deflect/disrupt APFSDS long-rod penetrators as well.
The pendulum started swinging back in the 1990s with things like top-attack guidance systems, explosively formed penetrators, and things like tandem-charge warheads, all of which are engineered to defeat tanks with modern composite or reactive armor.
We’re actually seeing the pendulum swing back for tanks, believe it or not, with the advent of active protection systems on the most modern tanks. These are essentially small radar systems coupled with some sort of countermeasure- some use small rockets, others projectiles, and still others use IR jamming countermeasures. Basically if the radar detects some kind of projectile on a trajectory that will impact the vehicle, it fires the countermeasure at it to destroy or disrupt it. Right now, these aren’t super-common, but they’re starting to be more and more common, especially in Western armies.
A big part of the problem we’re seeing in Ukraine is older T-72 tanks with only ERA being attacked by modern top-attack missiles- essentially the results of the 1990s pendulum swing away from tanks.
I suspect that if we were seeing top of the line T-90 tanks with composite armor, ERA and APS well supported by competent infantry, we’d see a LOT less destroyed Russian tanks.