The foam is intended to work as a spring, but it can only do that if it is placed into a spring-like state. The nature of the foam block is that it has a natural rest state where it is 'relaxed' -- just like an unloaded spring -- and in such a state it doesn't follow the properties associated with Hooke's Law.
Just like the springs in the shock absorbers in your car, they need to be compressed into their working range before they work as intended.
If you imagine a light car sitting on very stiff springs, any vibration from the road will just be passed straight into the car and its occupants, and you'll get shaken to bits as you drive along. The springs have insufficient compliance to absorb the vibration energy, so they just pass it on.
In contrast, if the car is heavily loaded, the springs go into compression, and now they absorb a lot of the bumps and dips in the road, giving the occupants a much smoother ride because the vibration energy is absorbed in the spring as it compresses and relaxes.
Foam-based speaker dampers work the same way -- and if they are insufficiently loaded it's like an empty lorry bouncing along the road where the vibration is passed straight through from the road to the lorry cab -- or from the speaker into the shelf or desk.
Load the foam properly, so it starts out partially compressed and spring-like, and it works like a properly loaded lorry, where the springs absorb the energy, giving the load a much smoother ride... and stopping any speaker vibrations from reaching the shelf or desk.
It ain't rocket science... but it is science!

H