气 wraps the upper-right corner, the modern chemistry radical for gases. It systematically marks elements existing as gas: 氢氧氮氦氟. Ammonia, though normally encountered as a solution, is named for its gaseous form.
安 supplies the sound ān directly — chosen to approximate the am- of ammonia / amine. Standard chemistry-coining pattern: gas radical plus an internationally suggestive phonetic, here picking ān because of its acoustic match.