How can you prevent sounds from traveling?
Sounds, once created, cannot be "prevented" from traveling. A "sound" becomes a sound only because it has already traveled, even if only for an instant. Because sounds are compression waves, they need a medium through which to travel. A sound will continue to travel until it as dispersed or been absorbed to the point that it can no longer be detected.
In a vacuum, there's an absolute lack of material. In this condition, a sound cannot even be created, let alone travel. So if you wanted to prevent a sound from occurring, attempt to make a sound in a vacuum. There will be no sound at all through the vacuum. However, even in this situation, the material you used in attempts to create a sound will transmit a sound wave.
If a sound as been generated and started travelling, it can be attenuated by absorption which limits or prevent the sound from being present although still very close to the "travelling sound". There are a variety of acoustic insulating materials that can be used for this absorption. Thick foam is used on conventional headphones to limit sound travel.
The one thing that is more effective than absorption that can be used is an active sound generator that can detect and transmit the inverse sound waves. This results in the sound waves being cancelled. This method is used by the sound-cancelling headphones.