DC Motor/Generator current flow
Back EMF and internal resistance are the main things that determine the direction and magnitude of the current flow in a DC brushed motor or generator
Back EMF comes from the speed that the motor shaft is turning, spin it faster and the back emf will have more volts.
in normal runiong the motor will reach a speed where the back emf mostly cancels the supply voltage and the difference in voltage divided by the internal resistance will get you the current through the motor (Ohm's law).
If you spin it fast enough that the back EMF exceeds the supply voltage the the
motor will act as a generator pushing current into the supply.
A third thing that determines the current is the strength of the magnetic field, this sets an upper limit on the current that a generator can produce, no matter how fast you spin it.
To answer your second question nothing would stop the generator from becoming a motor, but if the spinning speed is fast enough it will be acting as a generator.
You could add a diode to prevent current from flowing the wrong direction.