The reaction involves nitrogen gas and hydrogen gas.
N2 + H2 → NH3
N2 + H2 → 2NH3 (balance nitrogen)
N2 + 3H2 → 2NH3 (balance hydrogen to balance the equation)
Thus 1 moles of nitrogen gas produces 2 moles of ammonia with excess hydrogen.
1 mole of nitrogen has a mass of 2 (14) = 28g so 14g of nitrogen = 14/28 = 0.5 moles of nitrogen
From the equation 0.5 moles of nitrogen in excess hydrogen produces 1 mole of ammonia with a mass of (14+3) = 17g of ammonia.