For imidazole, the lone pair of pyrrole-type nitrogen (the one with hydrogen) is involved in aromaticity of the whole compound, as it contributes two π-electrons in addition to four of those from carbon-carbon or carbon-nitrogen bonds, which makes it 6, which is a classical sign of Huckel aromaticity. In fact, this NH-nitrogen tends more to act as an acidic center than as a basic one, as it loses its hydrogen when treated by strong bases, like $\ce{NaNH2}$.
The pyridine-type nitrogen has its lone pair out of ring conjugation, thus it can act as a acceptor of hydrogen ion, placing its two electrons into a vacant orbital of a $\ce{H+}$.
For reference, you can see any heterocyclic chemistry textbook. I prefer the one authored by Joule, Mills. Or this.

When it comes to 2-aminoimidazole, this publication (which is unarguably very old) says all three nitrogens are involved in protonation, because the structure is a derivative of guanidine, a strong organic base. Which seems only legit to me if it said that the contribution of pyrrole-type nitrogen is negligible, as aromaticity is ruined in that case. I could also predict that exo-aminogroup gets protonated more likely, as its basicity is somewhat higher: its lone pair is on a sp3-orbital, rather than the lone pair of endo-nitrogen (the one without H), where it is on a sp2-orbital, thus, the contribution of s-orbital is higher and it is closer to the nucleus of nitrogen atom, decreasing its availability to act as a covalent bond acceptor.
