This happens due to resonance (A phenomenon in which a vibrating system or external force drives another system to oscillate with a greater amplitude at a specific frequency). The lamp on top of the piano has a resonant frequency equal to one of the notes being played.