If the car is running
If the noise is "clacking" and the car is running, it is typical when the break pads or shoes are worn, there is dirty in the calipers or drum preventing the system to be relocated correctly to the right position for its elements (pads, springs, pins, etc), the break pistons are applying force to the pads/shoes but then leaving too much gap between them when released.
It may also be a slightly bent disk or oval drum, adding vibration to the system. What makes the noise is commonly the pads/shoes hitting their pistons or the retaining pins. When you press the pedal, the pads/shoes gets against the disk/drum therefore the system elements kinda tights in together and the noise disappear. If aside the noise you can sense some vibration in the pedal, even just almost un-noticeable, then the disk/drum are bent for sure.
If the car is not running
The noise then will be a "hiss" or "sissing", it may be an air leak at the booster or the linkage to it and its vacuum hose, or even the hose as well. But that may also induce the engine to rev up because the hose is attached to the intake manifold, and any "external" air leak will make the engine rev up. Check that as well.