There are 2 important ladders in play here. If the first ladder does not work for black, then black should not even think about playing the hane. Because white can simply cut in that case (as seen in following diagram).
If the first ladder does work for black (unlike the previous diagram) then the hane becomes possible.
However now white should watch his steps very carefully! There is a 2nd ladder. If this ladder does not work for white then he should simply capture the single stone as seen in the main diagram of this sequence.
However if this second ladder does work for white. Then white can initiate the following sequence. The resulting ladder works for white, so it is possible to play like this.