Multiple Voltage Sources using a single Ground
how does it know to go back to the battery and not the ground on the
  Arduino chip


The most negative point on the system is where the current heads for just like a plug hole in a bath - this is where the water wants to go because of gravity. If there's a ridge in the tub (equivalent to one amongst several ground wires having slightly higher resistance), the water (or current) will tend to go round it to find the lowest point.

Your wiring schematic should also look like this so that there is no chance current taken by the motors are drawn along digital ground wires. It's called star-pointing: -