An "h" may be used to prevent the "g" from being soft, as in spaghetti, but there is no need for an "h" in the mentioned proper names.
In Lamborghini, there is actually a need for the h because it would otherwise be pronounced with a soft g. As for the other two, I think that gh represents a sound that doesn't exist in English (similar to German or French r sound). So it's sort of a transliteration of the native name into English. Just like in the name Khrushchev, for example, where kh represents the Russian х (sounds like the German ch).
<H> is a letter that's used in English largely to modify other letters, like <TH>, used for both /ð/ and /θ/, <SH> for /ʃ/, and <CH> for /tʃ/. This is for native English words that may have been borrowed centuries ago, but now are felt to be English.
In proper names from other languages, like Afghanistan, Baghdad, and Lamborghini, we are not dealing with English spelling, however. Either there are different spelling conventions involved, like the <GHI> in Lamborghini, which represents /ɡi/ instead of /dʒi/ in Italian spelling, or there are different writing systems involved that aren't necessarily even alphabets.
Baghdad, for instance, is an Arabic word, spelled in the Arabic abjad, and contains the Arabic letter for the uvular fricative consonant [ʁ], which does not occur in English, but is often transliterated into English as <GH> -- but it's often transliterated in other ways, too; remember the fuss recently over whether the dictator's name was sposta be spelled Kaddaffi, Ghadaffi, Qadafi, Khadhafi, or what?
Similar remarks apply to the <GH> in Afghanistan; though I'm not sure which language it originally represents, it is written using Arabic letters by a Muslim population, and there's that [ʁ] again.
Basically, there is no consistent relation between the spelling of English words and their pronunciation; this is especially true for proper nouns, and most especially true for proper nouns borrowed from foreign languages. They all have to be learned separately.
Sorry, but that's the way it is.