It's an interesting story, actually. One tends to think of 9-1-1 as a modern invention, but in reality there was only a window of time where such services weren't the norm, during the age of the telephone anyway.
Early telephones were entirely operator based. And in fact even after the advent of the rotary dial it was trivial to connect to an operator, of which there were an inordinate number of. One could simply call the operator (e.g. by dialing 0, in the rotary dial era) which would connect you to a local human being who could then connect you to any local number, such as the police, hospital, or fire department. Even in the era of the rotary dial telephone many calls were made by calling the operator and asking to be connected to a number or an individual. Indeed, it was often necessary to talk to an operator merely to place a long-distance call to a different area code.
Through the 1950s, '60s, and '70s the telephone system became progressively more automated, and local human operators became increasingly less common. In the 1950s ten digit calling and "subscriber trunk dialling" saw rollouts across the US, reducing the need to have human operators in the loop for routine calls. In the 1960s trans-oceanic cabling had increased throughput sufficiently so that most international calls could be connected automatically rather than requiring queuing or scheduling (which had necessitated human operator intervention).
By the 1970s automated electronic telephone switching had become ubiquitous, as had touch tone phones, and the vast majority of calls in the US were completed without operator assistance.
In parallel to these advancements there was the perceived need for deliberate coordination of emergency services. Operators were not necessarily available 24/7 even in the era when they were ubiquitous, nor did they have specialized training or equipment for dealing with emergencies or dispatching emergency services. The UK began experimenting with special emergency service phone numbers quite early, with the "999" system beginning in 1937 in the London metro area (after a bit of a scandal involving a fire in 1935 that had taken the lives of 5 people wherein a neighbor's call to the fire department had been queued for several minutes).
In the US the National Association of Fire Chiefs made a recommendation for a unified, simple number for reporting fires in 1957. After gaining momentum for several years a Presidential commission forwarded the recommendation for creating a nationwide universal emergency number in 1967. In 1968 the number "9-1-1" was chosen and became the official emergency number for the US. However, deployment took significant effort and time and it wasn't until the 1990s that coverage across the US was nearly ubiquitous. An interesting consequence of the 9-1-1 rollout was that a lot of little country roads that had remained unnamed since time immemorial were forced to be named. So that every residence had a unique, canonical address that could be entered into the dispatch system and so that the directions to any address could also be given by directing emergency services personnel along named roads. Many of them were named for the sole nearby residents or simply given numerical designations. (This work was carried out through many local 9-1-1 road naming boards.)
Interestingly, many other services in a similar vein have existed before 9-1-1. For example, dialing 4-1-1 for directory assistance dates back to the 1930s. And in the late 20th century 2-1-1 in many American cities would connect you to either a long-distance operator or, in New York, to an automated credit request system for mis-dialed calls (today it is used to provide non-emergency health and social services referrals such as for counseling, child care, food banks, etc.)
I would like to know the same about Germany, not just the US