The first problem with your question is that ‘sound’ in languages can mean at least two things:
a phoneme, i.e. something that if changed will change the meaning of the word. English example: /b/ and /p/ are phonemes because bear/pear or beer/peer are different words that you can understand without context. Phonemes are always distinguished as different ‘sounds’ by native speakers.
a phone, i.e. a sound that may be heard distinctly from other similar sounds by a speaker but does not serve to distinguish different words (either both sounds give the same words but differ e.g. in accent, dialect, social status or a given environment enforces a certain sound with the other being a mispronunciation).
In general, the different ways to pronounce vowels across the different varieties of English (US, UK, Australia, New Zealand) can be considered phones. German has a nicer example: the digraph ch can be either [x] or [ç] depending on whether it is preceded by a back or front vowel—however, some dialects tend to strongly prefer [x] over [ç]. Phones may be recognised as different sounds but don’t have to be.
It is often, but not always the case that different phonemes will be represented by different symbols. However, consider English th which can either be voiced as in the or unvoiced as in three (I believe a more accurate description is fortis/lenis nowadays) and the difference can be considered phonemic.
It is sometimes the case that different phones will be represented by different symbols. However, that is far less common: Korean uses the same symbol for the [s] and [ʃ] sounds (which are allophones as far as I’m aware) and I have already given the example above with German’s ch.
Most of your Arabic examples actually represent different phonemes as far as I can tell (the two s variants certainly do) and thus aren’t ‘the same sound’ by any possible definition except in the eyes of someone coming from a language that happens to not distinguish between those phonemes.
Incidentally, this can be a two-way problem. English differentiates between /s/ and /ʃ/ for example, while in Japanese they are allophones (the sound is pronounced [ʃ] if /i/ follows; while there is a difference between /sa/ and /ʃa/ that is actually one between /a/ and /ja/); Finnish traditionally doesn’t have any approximation of a /ʃ/ sound at all. So a Finn might ask ‘Why does English have random orthographic h after some s?’
The second problem is within writing system: Many languages do not have their own writing system. In Europe, the majority uses either the Latin or the Cyrillic alphabets which can be said to be the original writing systems of Latin and Church Slavonic meaning that it can be said that no modern European language except Greek uses its own writing system.
The traditional Latin alphabet offers 26 letters. For some languages, that is technically sufficient: Finnish, for example, has only eight vowel phonemes and thirteen consonant phonemes meaning it could make do with 21 letters. This disregards vowel and consonant length, which is phonemic for all vowels and most consonants but can easily be written as a doubled letter (and is done so, no exceptions). Eight vowel sounds are sadly more than Latin distinguished, but Finnish makes use of ä and ö to overcome the two unbridgable gaps rather than misappropriating letters. I hear Hawaiian and a couple of other languages have a similarly small repertoire of phonemes.
French, being a direct descendant from Latin, could be assumed to be another good candidate but it isn’t. Off the top of my head I count ten vowel phonemes, three semivowels and sixteen consonant phonemes (total: up to 29 distinct letters) but I likely missed a bunch. I don’t even want to get started counting English but rest assured you’re well outside the 26-character limit.
In most of Europe, Latin was highly regarded as a language for the educated since the fall of the Roman Empire. It was also the language of the western church, so the Latin alphabet rapidly superceded any other remaining writing systems (like Norse runes) that were around before it. However, not all languages in Europe are Romance and they did a varying job of coming up with a way to represent the needed sounds with the 26 Latin letters. Elsewhere, other writing systems enjoyed a similar status: most of the Islamic world wrote in variants of the Arabic writing system (the language of the prophets) while the status of Chinese in East Asia led to the Chinese writing system being adopted in Japan, Korea and Vietnam. In many a case, the prestigeous writing system didn’t actually fit the target language well and various remedies were devised. The most radical one was probably Turkey switching to the Latin alphabet in the early 20th century—while Arabic’s inability to adequately represent Turkish out of the box may have played a role the prestige of Europe at the time probably played a greater one.
The third problem I want to point out is that languages aren’t static: their spoken forms tend to evolve. In German, the way the letter r is pronounced has changed significantly during the last century with a new variant almost entirely surpassing the previous variant. (All variants of pronouncing /r/ are still valid, but one speaker will stick almost entirely to one single variant.) In a similar manner, English underwent something called the Great Vowel Shift and Japanese had a number of shifts involving the /h/ and /w/ sound, effectively merging a number of different syllables.
Writing systems tend to be much more static than spoken languages, however. While the German /r/ cannot really be expressed in writing (as it merely represented a change from one allophone to the next), the vowel shifts of English is why English pronunciation maps with spelling so extremely poorly: take the word extremely where each e is pronounced differently—one is even pronounced almost like the final y, at least in my variety of English!
Writing systems aren’t acquired naturally like spoken language; they have to be taught, meaning that there is a teacher who at some point defines what the student learns as ‘correct’ and ‘wrong’. In Japanese, the culture of taking for granted everything the teacher said led to very antiquated spellings due to numerous sound changes having been ignored until a couple of reforms in the early 20th century ‘put it right’ again and (almost) aligned spelling and pronunciation.
Depending on how flexible your writing system is, how much emphasis is put on spelling as you speak rather than as you learnt, a writing system may adapt quickly to new pronunciations or not adapt at all. I would expect Finnish with its very phonemic spelling to mirror any cross-phoneme pronunciation changes almost immediately and English to ignore them completely within all reasonable timeframes to give just two rather extreme examples.
After this very long rambling, I finally turn to answer your actual question. In principle, when a writing system is newly invented by a language you will end up with a very good to perfect phonemic mapping of that language’s sounds and symbols in the writing system at that time when it was devised. A good example for this is the Korean writing system which was consciously invented around 500 years ago and includes one symbol for each phoneme (disregarding vowel length) in use at the time.
The same is generally true if a language adopts another language’s writing system. Ideally, a symbol exists for approximately every sound and these can be used in that way. Potentially, a number of symbols have to be invented (be it using diacritics, as is the standard for most Latin-based scripts, or by inventing a wholly new character, as was often done in Cyrillic scripts) for sounds the language you copied from doesn’t have. Also, a number of sounds may be similar to the same phoneme in your language (but different phonemes in the alphabet’s origin language) so you can choose to keep them both and assign by any arbitrary rule or discard one.
All of this essentially happened, when Greek copied the Phoenician alphabet. The original Phoenician O was split into two Greek symbols—omicron and omega or small and large O—because of Greek phonetic needs. The Phoenician Q (Koppa) gave rise to three Greek symbols: koppa, psi and phi. Greek needed to distinguish between aspirated and nonaspirated stops and so made sure that these were present. At the same time, it did not distinguish between K and Q so Q quickly fell into disuse (not before the Romans copied it, though). The result was a writing system that worked well for Ancient Greek.
Fast forward almost three millennia and the Greek spoken language had changed—but spelling was still somewhat consistent with the Ancient Greek predecessor, kept ‘alive’ as a classical language of the educated. If you now look at Greek orthography—and if you like things organised like me—you may sense immediate frustration at so many spellings giving the same sound. The point is, they were all distinct at a time long ago but have since merged.
One paragraph above, I have mentioned that the Romans copied the Greek alphabet (with the Etruscans acting as an intermediary). They did so before the Greek variant they copied from eliminated Q, and because of the phonemics of Etruscan—which did not, for example, know a [g] sound—they were suddenly left with three ways to write /k/: C, Q and K. In classical Latin, these were eventually regularised so that C is used normally, QV is used to represent /kw/ to not confuse it with CV (/cu/) and K practically falling out of use except in words from Greek. Back then, that was great, but centuries down the line in modern Italian the /k/ sound changed to /tʃ/ before front vowels. Suddenly, one letter represented two different phonemes—not allophones, compare the minimal pair che and c’è.
These considerations—sound change since adoption of the writing system coupled with rigid spelling conventions or inflexible source that wasn’t expanded—explain the perceived anomalies of Hebrew and English while your Arabic examples seem to stem from incomplete understanding of Arabic phonology.
To ‘explain’ the Sanskrit case: well, it turns out that your definition of a ‘letter’ or ‘character’ is not directly transferable. Not all writing systems follow the general Latin/Greek/Cyrillic idea that a specific, separable ‘letter’ or a group of these represents a single sound (consonant or vowel). Most writing systems can be grouped into one of the following classifications:
- logophonetic system
An alphabet is what you know from the Latin alphabet: there are distinct consonant and vowel letters which can be arranged to give syllables (like twup) or unpronouncable gibberish (like xptk although you can pronounce that if you really try).
The Arabic and Hebrew writing systems are more or less abjads: most symbols represent consonants and the vowels connecting them are often not written. Only select vowels (e.g. only long ones) get their own symbol. Other vowels can be indicated by diacritics but don’t have to.
A syllabary is when a single symbol always or usually corresponds to an entire syllable (and there are no individual parts of a symbol that hint at the sound). So in Japanese, く represents /ku/ but there is nothing connecting it to any of the other /k-/ syllables (かきけこ) or any of the /-u/ syllables (うすつぬふむゆる).
An example for a logophonetic system is Chinese. While a symbol represents a pronunciation it also comes with an intrinsic meaning and different symbols with different meanings are used to represent words that sound the same. Japanese copied that somewhat so it also has a logophonetic component to it, allowing to distinguish the homophones 海鳥 (seabird) and 会長 (chairperson/president; both /kaitʃo:/) or 切る (to cut) and 着る (to wear; both /kiru/) in writing.
Finally, abugidas—and as you may have guessed because I left it out, Sanskrit falls into this category. In an abugida, the smallest possible symbol represents a consonant with an inherent vowel, but adding a specific part to it will result in a symbol with the same consonant but a different vowel. Thus, looking at a symbol representing a syllable, you can identify a consonant part and usually a vowel part (but the vowel part can be absent if the inherent vowel is used). Of course, sometimes vowels turn up at the beginning of a word without a preceding consonant. While abjads would traditionally write a null consonant here, Sanskrit has individual symbols for the vowels. Your first column of Sanskrit ‘doublings’ represent the lone vowel while in the second column it is attached to a (consonant) syllable symbol.
I sincerely apologise to everyone who worked their way through this wall of text.