Transistor, PWM and LEDs

Latest developments: I replaced the CTPN2222 transistor with a pin for pin dropin BC547.
And to my surprise, the logic is no longer inversed.
I am glad but I still don't understand what is the difference between these two transistors that would make the logic inverted in the PN2222 and not in the BC547?