Apparently Dr. Soong built Data with the Gilbert & Sullivan failsafe. When activated (by singing a few verses from any of their works), it causes a feedback loop, forcing Data to do nothing, but sing along allowing him to be neutralized.

That’s my only explanation for this scene XD