According to this 1953 article by David Allen Stein, the pronunciation since the 1850 incorporation had been the one with soft G, and the hard-G variant was a pseudo-Spanish pronunciation that grew out of a "craze" around the turn of the century "to give every new street, every new subdivision, every new town a 'Spanish' name ... not limited to Southern California but spread over the state." If this is correct, the hard-G variant may be a sort of hyperforeignism on the assumption that that was closer to Spanish [ˈaŋxeles] (or whatever the Spanish pronunciation was thought to be).
This is given credence by this letter sent to a newspaper by Charles Fletcher Lummis, an LA librarian who vigorously advocated for the hard-G pronunciation:
Spanish G before E has no precise equivalent in English. It is almost exactly the German ch in "buch." Those who call the name "Ann Hell" are less outlandish than the "angle" people; but they are still far from the fact.
So even though he was well aware that [ɡ] wasn't a good approximation to [x], he advocated for it anyway because it was at least closer than [dʒ].
The hard-G pronunciation soon lost favor, with endorsements of the soft G coming from the US Board on Geographic Names in 1934, and from the city of Los Angeles itself in 1952, as documented in this LA Times story. Again assuming Stein is correct, this was a return to an old form.
To address your question more directly, I think Stein and Lummis's accounts imply the hard-G pronunciation arose from an earlier, more faithful attempt at approximating Spanish, and [ɡ] was inserted as a result of epenthesis. Here's what I think happened:
- The Spanish [x] was approximated by /h/, but this was soon dropped as is common with /h/ occurring after stress and between voiced sounds (cf. vehicle, Birmingham).
- The second vowel in Angeles lenited to a schwa (if not already), which gave rise to either a syllabic realization of /əl/, i.e. [-ŋl̩-], or a complete elision of the vowel, i.e. [-ŋl-].
- Since [ŋl] is quite rare in existing words (cf. angle, English) except across morphological boundaries (wrongly, meaningless), [ɡ] was inserted.