Why are nitrogenous hydrocarbons sometimes colorful?
Introduction from Color Introduction

&quot;What causes a compound to appear as being colored? The answer to this question lies in the way that electromagnetic energy interacts with matter. The portion of the electromagnetic spectrum that is of interest to this discussion is the visible portion, or what we call light. This visible light includes all the colors that we perceive: violet, blue, green, yellow, orange, red, and the various combinations of these. Although light can interact with matter in several different ways, this discussion will limit the modes of interaction to absorption and reflection.&quot;
In most cases color comes from the excitation of electrons due to an absorption of energy performed by the chemical. But - there is still ... :)
&quot;(...) The vast majority of simple inorganic (e.g. sodium chloride) and organic compounds (e.g. ethanol) are colorless. Transition metal compounds are often colored because of transitions of electrons between d-orbitals of different energy.
Organic compounds tend to be colored when there is extensive conjugation, causing the energy gap between the HOMO and LUMO to decrease, bringing the absorption band from the UV to the visible region. Similarly, color is due to the energy absorbed by the compound, when an electron transitions from the HOMO to the LUMO.(...)&quot; Wiki - color of chemicals

You can also assume that if a compound has double or triple conjugated (2 or more) bonds it can be colorful.
To answer your question: in alanine there is almost no chance to make double bond in amine group (e.g. $\ce{=NH}$), but nitrogen group ($\ce{O-N=O}$) has a capability to conjunct with other double bonds (can be also delocalized electrons or pi electrons - e.g., nitrobenzene)