The extent of hydrogen bonding depends upon electronegativity and the number of hydrogen atoms available for bonding.
Among nitrogen, fluorine, and oxygen, the increasing order of their electronegativities are N < O < F. Hence, the expected order of the extent of hydrogen bonding is HF > H2O > NH3. But, the actual order is H2O > HF > NH3.
Although fluorine is more electronegative than oxygen, the extent of hydrogen bonding is higher in water. There is a shortage of hydrogens in HF, whereas there are exactly the right numbers of hydrogens in water. As a result, only straight chain bonding takes place.
On the other hand, oxygen forms a huge ring-like structure through its high ability of hydrogen bonding.
In case of ammonia, the extent of hydrogen bonding is limited because nitrogen has only one lone pair. Therefore, it cannot satisfy all hydrogens.