How a DC motor works when connected to a power supply but no resistor?
Two reasons.


The motor is itself a resistor. Look at all that wire inside it. This limits the current it takes when stalled. Not a lot; but a motor that takes 1 Amp when running may take 10-15 Amps when stalled, due to that resistance alone.
The motor is also a generator. When it's running, it generates a voltage proportional to its speed. That opposes the driving voltage, leaving only the difference between these voltages across its internal resistance. Which reduces the current still further. (In a motor, this generated voltage is called "back EMF". In a generator, where you turn the shaft mechanically, it's just called EMF)


Load a motor and you'll slow it down. That decreases the generator voltage, (back EMF) increasing the voltage across its internal resistance, increasing the current, to produce enough torque to drive that load.