All the devices that use motion sensors to try to count your steps aren't totally accurate. They need to try to detect the motion that your body makes when you take a step and count that, but they also need to ignore other movement, such as when you're driving along a bumpy road or shaking your leg when your phone is in your pocket. It's likely that when your holding your phone in your hand that you're also moving it around a bit and that extra motion is enough to make the phone think that you're not actually taking steps. Since it only counts flights of stairs if you take steps as you go up (or maybe down) and it doesn't think you're taking any steps then it won't count those flights either.
You could try to walk up some stairs with your phone in your hand and make an effort to hold your phone perfectly still relative to your body. My guess would be that it would count flights of stairs as accurately as it does with the phone in your pocket.