Switching LED with a transistor
You're neglecting the current amplification effect of the transistor. The maximum allowed (to a point, called "saturation") collector current is equal to the base current times the current gain of the transistor, labelled "hfe". By restricting the current into the base one can restrict the current into the collector and hence into the LED.

Note that hfe varies with multiple factors, and so should not be used as a safety mechanism to prevent the LED from burning out. Keep the series resistor.

Also note that "switching" with a transistor involves driving it into saturation, so technically the second circuit isn't even switching.