When the pawn stands ahead of the rook instead of shielding the king, the rook has no protected post and the queen wins by combining king approach with threats against the pawn.
Rook and pawn do not always hold. Here the pawn on h5 is in front of the rook on g6, and the king on h7 shields nothing. The rook's squares on the sixth rank are not protected by the pawn, and the pawn itself is a target.