Batteries are good at storing electrical energy for a long time (shelf life) and at providing modest currents at modest voltages. But batteries typically are not good at providing very large currents. That's not a good fit for a camera flash, where you want a lot of electrical energy to be transformed into light in a very brief amount of time. So a camera flash is typically connected to a capacitor, which can discharge very rapidly. The battery charges the capacitor over several seconds, and then all of that charge is sent through the flashbulb in an instant. If you've ever done a homework problem with $RC$ circuits and their time constants you can start to see how this part works.
The whine comes from the charging circuit, which typically uses a design pattern called a "boost converter" to charge the flash capacitor to a higher voltage than the voltage on the battery. In general, boost converters have an inductor which is briefly shorted across the battery, to build up some current, and then switched to the load to be charged. Because inductors hate to change the current that flows through them (due, roughly, to the inertia of the magnetic field), the load briefly receives something more like the battery's shorted current than what the battery would provide on its own. Exactly how much depends on the details of the components involved, and on the switching frequency.
There are some clever designs for self-oscillating boost circuits. These usually have two inductors connected from the battery to both sides of a transistor, which acts as the switch. Current through one inductor to the transistor's base makes the transistor go conducting, effecting the short across the battery. When all the battery's current is going through the short, the base current is reduced and the transistor switch opens; now that current has to go to the load. As the load current falls, the base current returns and the transistor switch is closed again. The oscillation can be enhanced if the two inductors also talk to each other as the two sides of a transformer.
In hobby electronics there's a very simple design of this type called a "joule thief" (what a pun!) which is very effective at driving medium-voltage loads from nearly-dead batteries. Searching the web for camera-flash circuits shows lots of similarities between those designs and the simple joule thief, but if you're not used to thinking conceptually about circuits you might get distracted by less-relevant pieces.
This kind of self-oscillating boost converter oscillates more slowly if the current is large and more rapidly if the current is small. And the magnetic fields in the inductors cause mechanical parts to move in time with the oscillation. Those kilohertz-ish motions make sound. That's the whine that you hear when a camera's flash is charging: a self-oscillating boost converter charging a big capacitor, with lots of current at the start and tapering away exponentially as the capacitor is filled with charge.