Moving membranes or piezoelectric materials obviously produce sound waves, but how can "purely" electrical circuits such as transformers or DCDC choppers (and others) often have an audible noise? Is the material microscopically expanding and shrinking with the current?
What you are really asking is how can electrical circuits cause small motions.  After all, sound is motion of the air.

The answer is that there are various ways electric fields or electric currents can cause forces or motions.  These effects are harnessed in the design of various transducers, which exist to deliberately cause or sense small motions.  However, the laws of physics that allow these transducers to function don't stop outside the transducer case.  They exist everywhere, so many things are unintended transducers.  The difference is that usually the effect is rather weak without it being deliberately designed for as in a transducer.

Some of these effects are:

Electrostatic force.  Two objects at a different voltage will have a force between them.  The force is proportional to the voltage and inversely proportional to distance.  This is the same force that allows a balloon to stick to your hair after rubbing it against a cat or something.  For ordinary circuits, this force is very weak, and conductors are held in place much more strongly than it.  Still, you can sometimes get audible sound from this with high voltage circuits.

Electrodynamic force.  A moving charge creates a circular magnetic field around it.  The magnetic field is proportional to the current, and can be made quite strong by looping the wire into a coil.  This magnetic field can be made to move things, and is the basis for how solenoids, motors, and loudspeakers work.

Moving charges likewise experience a force if flowing thru a magnetic field of the right orientation.  Most loudspeakers actually work on this principle; they are made so that a strong permanent magnet is fixed and the coil moves, which in turn moves the center of the speaker cone.  The same thing happens in any inductor.  Each piece of wire with current thru it experiences some force due to the overall magnetic field.  Some of the buzzing you hear from transformers is individual pieces of wire moving a little bit as a result.

Piezoelectric effect.  Some materials, like quartz for example, will change their size or shape slightly as a function of applied electric field.  Some small earphones work on this principle.  There are also "crystal" microphones that work on this principle in reverse, meaning applying force to the crystal causes it to create a voltage.  Common barbecue grill ignitors work on this principle by whacking a quartz crystal hard and suddenly enough to create a high enough voltage to cause a spark.

Some capacitor materials exhibit enough of this effect that when rigidly mounted on a circuit board can cause audible sound.  I had to respin a board once and replace a ceramic cap with a electrolytic just because the ceramic was causing annoying audible whine.

Magnetostrictive effect.  This is the magnetic analog of the piezoelectric effect.  Some materials change shape or size depending on the applied magnetic field, and this effect works in reverse too.  I have worked on magnetic sensors that exploited this effect.

Materials in transformers and inductors are chosen to not have this effect, but a small amount is there anyway.  The core of a inductor actually changes size very slightly as the magnetic field changes.  This can cause audible sound, especially if the inductor is mechanically coupled to something that presents a greater area to the air, like a circuit board.


