That was done years ago, as the Legged Squad Support System.[1] It sort of worked, but was too expensive and too noisy, being powered by a small IC engine. The USMC abandoned the project in 2015.
Boston Dynamics' big accomplishment was to get enough funding to actually do anything useful in mobile robotics. Most university robotics projects were a professor and a few grad students, and took forever to get anything. BD spent upwards of $100 million of DARPA money over a decade and got some working demos. Then they were funded by Google, and now Softbank.
Big walkers have been built. The Timberjack, from John Deere, is probably the best example.[2] This is a large six-legged off-road machine equipped with a long arm with a chainsaw. It worked but was not cost effective vs. wheeled systems.
The message is that with enough money you can do legged locomotion, but so far, there are few profitable applications.
[1] https://en.wikipedia.org/wiki/Legged_Squad_Support_System
But, I read somewhere that only 20% (ish) of the earth's surface is accessible by wheeled / tracked vehicles. I guess the important part is that's where the people are.
Moreover, of the places that are accessible to tracked vehicles, many are accessible only to small tracked vehicles, smaller than a typical car, and not at all to tank-sized vehicles.
Much depends on scale. BD is working towards a robot-donkey, something that can follow soldiers over rough terrain. At scales much larger than a horse, such robots already exist and are already much more mobile than soldiers in most terrains. These robots are called tanks. Or trucks.
Once a vehicle is carrying a large enough load that it will not fit between the trees and so cannot follow soldiers into forests, legs are not very useful. Wheels and tracks are better than legs, particularly in soft/wet terrain. So large walking robots are likely never going to happen. The MechWarrior fantasy will have to live on in things not much larger than a horse, things that can fit between trees and along footpaths.