Control speed of DC Motor with potentiometer

PWM = Pulse Width Modulation

Pins 3, 5, 6, 9, 10, and 11 can do PWM "analogWrite()". When you say:

analogWrite(3, 0); // Pin 3 is off all the time
analogWrite(3, 64); // Pin 3 is on 1/4 of the time and off 3/4 of the time.
analogWrite(3, 128); // Pin 3 is on half the time and off half the time.
analogWrite(3, 192); // Pin 3 is on 3/4 of the time and off 1/4 of the time.
analogWrite(3, 255); // Pin 3 is on all the time

The pulses are quite fast so for LED's and motors it acts like an analog signal.

If you use a pin that can't do PWM you get LOW for all values below 128 and HIGH for all values above 127. That is why your motor on Pin 2 is doing just OFF (LOW) and ON (HIGH).