9 moles of H2 means you have a total of 18 moles of H2 (9*2). In NH3, the hydrogen comes in sets of 3 (hence H3 at the end) 18/3=6 therefore you need to have made 6 moles of NH3 to satisfy it, since you have enough N2 this can work so you make 6 moles of NH3