Driving LED using SN74HC164 and transistor. Apparently this schematic works but I don't understand why!
What you may be missing is that Q1 is acting like a voltage regulator.  It's actually an emitter-follower and the emitter voltage is approximately whatever voltage is on DS1EN less about 0.7V.  If DS1EN is a 5V signal, the emitter is sitting at about 4.3V.  If DS1EN is a 3.3V signal, the emitter is sitting at about 2.6V.

You don't say what color the LEDs are.  Red LEDs drop about 1.7V, old-school green &amp; yellow LEDs drop about 2.1V, modern green, blue, white LEDs drop about 3.2V.  I don't remember what the forward voltage of a modern yellow LED is - sorry.

You can also assume that the output LO voltage from the 74hc164 is anywhere from 0.1V through about 0.5V if the LED current is less than 10 mA.

So: the LED current is going to be about: (voltage @ Q1e) - (Vled) - (hc164 Vlow) all divided by 100 Ohms.  You need to fill in the missing information.