Why do we write NH3?
According to current nomenclature rules, $\ce{H3N}$ would be correct and acceptable.  However some chemical formulas, like $\ce{NH3}$ for ammonia, that were in use long before the rules came out, are still accepted today.