It actually wasn't a "lucky guess".
An iron core transformer ALSO just happens to be an electromagnet that changes it's polarity rapidly if you put AC current through it's windings. In fact, with 60 Hz AC current going through the windings, one end of the iron core of the transformer will go from a magnetic north pole to a magnetic south pole and then back to a magnetic north pole 60 times per second, and so if the transformer can move, even slightly, and is in the presence of something magnetic that it push/pulls on, the transformer will vibrate back and forth at 60 cycles per second.
Jamming a toothpick behind the transformer simply prevented the transformer from moving. That, in turn, prevented it from creating sound waves in the air, and that in turn "made it quiet". If it were held down to that "box" with screws, then tightening the screws to fasten the transformer down more tightly woulda done the same thing. By preventing the transformer from moving, you prevent it from creating sound waves as a result of that movement.
Now that you know why the transformer will "buzz" or "hum" under the right conditions, determining that the noise was most probably coming from the transformer was, quite honestly, a "no brainer" (to be perfectly truthful).
I expected it was probably the transformer, but for $15, it's a good idea to have a mechanic's stethoscope in your tool collection. That tool will allow you to pinpoint the source of noises in appliances and all types of machinery, and will normally pay for itself by just letting you know where the problem is.