It looks like the motor is receiving two positive sources of voltage:
one coming from pin 9 after it goes through the transistor-- then
another coming out of the 9v battery, down the power rail, and into
the motor.
Pin 9 provides a signal, not power. And the signal is applied to a NMOS transistor gate. (Or, at least, I think so if the circuit works okay. I can't be sure, because your picture doesn't specify the exact device involved and they can be packaged differently.)
I think this signal is a gate voltage. It doesn't directly connect to the motor. Instead, it signals NMOS transistor to connect the other two pins it possesses together.
Why is the power from the 9v battery necessary?
You'd mistakenly believed that Pin 9 provides a voltage to the motor. But it doesn't. So the motor needs access to a low impedance voltage source, which in this case is your \$9\:\textrm{V}\$ battery. Note that I said "low impedance." The \$5\:\textrm{V}\$ power supply for your Arduino is also low impedance and it could have been used, too. (Depending on the motor and whether or not it really needs the full \$9\:\textrm{V}\$ to operate well.) But you could not have used Pin 9, which is not a very good voltage source and couldn't run the motor on its own. Pin 9 can signal with voltages. And with very low power devices, like LEDs, it can power them, too. But it cannot drive motors. It just doesn't have the capacity to handle that. So, instead, Pin 9 is used to signal an NMOS device to do the work.
I thought the transistor's purpose was to modify the electrical
current so that it was capable of operating the motor.
This transistor is operating like a switch. And just in case you were imagining differently, a transistor cannot create current out of thin air. A power supply provides the current compliance.
Further, if the 9v battery is connected to the motor, why is that in
itself not spinning the motor?
It is.
I don't understand how everything's flowing back to the leftmost
ground rail. From the perspective of the motor, one wire is attached
to the positive lead of the 9v battery and the other wire is attached
to the gate coming out of the transistor. How is this thing grounded?
The \$9\:\textrm{V}\$ battery doesn't need to go through the leftmost ground rail. There is a bottom horizontal wire in the image which connects the (-) of the \$9\:\textrm{V}\$ battery to the (-) of the Arduino power supply. But that is there to set up a galvanic reference against which the NMOS gate is then driven. This allows the otherwise single-ended Arduino output on Pin 9 to do its job.
The positioning of the diode throws me off even further. My
understanding was that their purpose in a circuit like that was to
prevent electricity from flowing back into the circuit from components
like motors, but in this circuit, it doesn't seem to be positioned
between the motor and the rest of the circuit like I'd expect.
It is arranged parallel across the motor, opposite to the polarity of the \$9\:\textrm{V}\$ battery (otherwise, it would conduct when the battery voltage was applied.) It's there to allow accumulated energy (evidenced as current) in the motor, when turned off, to have a galvanic path to move through and to allow the magnetic field to discharge its energy in a managed way.
I think the circuit looks like this:
simulate this circuit – Schematic created using CircuitLab
Software must be monitoring the switch and then driving the NMOS switch to operate the motor. Perhaps you can slightly better see that a shared ground would be required in order to operate the NMOS switch's gate.
Best Answer
Some non-math beginner concepts:
All motors are generators. Suppose your permanent-magnet-type DC motor generates 9V when the shaft is spun at, say, 100Hz or 6000RPM.
This means that, when the motor is connected to a 9V battery, it will speed up to 6000RPM, then remain at that speed. When it's up to 6000RPM, it draws zero current (ideally.) That's assuming that bearing- and brush-friction is insignificant, and the rotor is in vacuum (so, no air is heated, with no wind blowing out of the holes in the case.) At max speed the current falls to zero because the motor(generator) is supplying 9V, and the battery is also supplying 9V of the same polarity. The two opposing voltages subtract to zero. The rotor keeps spinning at a constant RPM. And, other than friction effects, it doesn't need any energy from the power supply. For a real motor, the entire supply current is caused by unwanted friction (and also of course by any mechanical-load wattage being drawn from objects connected to the spinning shaft.)
In other words, it's not easy to calculate the current a real motor will draw from its power supply. The current depends on internal friction of bearings and brushes and wind/fan effects, as well as depending on the amount of work (wattage) the motor shaft is performing.
With DC motors, the RPM of the shaft is proportional to the drive voltage and the generated voltage. If a motor runs at 6000RPM when connected to 9V, it will run at 1/3 the speed if powered at 1/3 the volts (so, 2000RPM for a 3V power supply.) There really isn't any such thing as a 9V motor or a 24V motor, etc. Those are just the operating voltages for a minimum bearing-wear and maximum brushes-lifetime. Ideally, any DC motor can be run at much lower voltage and RPM than its spec-sheet voltage. And, any DC motor can be connected as a generator, and used as an RPM-sensor: the output voltage is proportional to rotor speed.
The rotor of any motor has mass, and can't speed up instantly. So, whenever you connect your DC motor to a 9V battery, it won't draw infinite current, and won't instantly jump to 6000RPM speed. It will however accelerate, and momentarily draw a large current while doing so.
All motors are flywheels. When first connected to a DC power supply, the motor speed increases, and kinetic energy is stored in its rotor. When hooked up and running with constant RPM, we can disconnect the supply, and the RPM will stay the same, and not instantly stop. (The rotor is an energy-storage device.) Then, depending on friction and work-wattage, the motor RPM will smoothly decrease, just like any flywheel which is performing work and losing its kinetic energy.
If we want to rapidly slow down a DC motor, we can disconnect it from its power supply, then connect it to a resistor. The motor acts as a generator (as it always does,) and drives a current in the resistor. The motor slows down, and the "braking resistor" gets hot.
In all, DC motors resemble capacitors, where the "charge" is the kinetic energy of the rotor-flywheel. DC motors draw a big current when first connected to a DC voltage. Then, the current decreases to nearly zero. Disconnect a spinning DC motor, and the power-supply voltage still remains on its terminals. What if we short those terminals? POW! A huge current appears briefly, and the rotor jerks to a sudden halt. We've discharged the stored mechanical energy, and the conductors end up at higher temperature.