The thing with phones is so much is built with backwards compatibility or at least similar design principles that any question like this you have to start at the first automated phone switchboards powered by strowger switches.
A rotary phone would issue a number of pulses as the dial spun. 1 pulse for 1, 3 pulses for 3, etc. Each pulse would trigger a strowger switch at local exchange, where it would start turning a dial on the switch with an equal number of turns to the pulses or receives. For a single digit dial it would just have one switch that rotates with the number of pulses of receives. For a much more common 3-4 digit number being entered it would take the rapid succession of pulses to turn the first dial, then after a sufficient pause any subsequent pulses turn the next dial, and so on. Once it runs out of dials to turn on the switch it connects the call to the line which may go to another phone or may simply go to another strowger switch awaiting additional pulses from the user dialing additional numbers.
For example user dials 5-5-5-1-2-3 with a pause between each digit as they dial. The first 5 sends 5 pulses in quick succession to the switch the phone is directly connected to (the local exchange) and that sets the first dial on the switch to 5, the user naturally pauses for a split second creating the pause the switch interprets as a completed dial then the user enters another 5 causing another 5 pulses to go to the switch at the local exchange. After the third 5 it connects to the next exchange likely without the user even knowing and the 1 is transmitted via the local exchange to the 555 exchange where a stroger switch turns to the 1 position from the single pulse, and so on. All of the switches that connect for such a call remain engaged and connected until they receive the disconnect pulse and then they kill the connection ending the call.
With the transition to DTMF tones, much of this same behavior of each switch is just waiting for exactly how many digits it expects then connects the call to the next place remained, and with modern digital and VoIP calls, they continue to emulate the same functionality of the strowger switches, where the exchange is expecting a specific number of digits to be entered, and the user will either enter the correct number of digits or receive an error and a call that doesn’t connect. There are actually still places operating analog telephone exchanges so everything is ultimately backwards compatible, and the security and design challenges of sending signaling over the same wire as voice have remained all thanks to the cost savings choices made by some dude with an amazing mustache in the 1880s. Or we can go even further back because the telephone was actually an innovation on the telegraph, originally designed as a solution for sending multiple telegraphs over a single telegraph trunk line.
Alexander Graham Bell, a pioneering audiologist who worked with deaf kids excitedly penned a letter to an individual at the Western Union Telegraph Company describing using different tones of beeps over the line to differentiate between different telegraphs, and then excitedly went on to describe how with enough different tones one could not only transmit a nearly infinite number of different telegraphs at once but one could theoretically transmit human speech! I’ve read scans of these original letters and you can just see the excitement building as Bell described that part
The thing with phones is so much is built with backwards compatibility or at least similar design principles that any question like this you have to start at the first automated phone switchboards powered by strowger switches.
A rotary phone would issue a number of pulses as the dial spun. 1 pulse for 1, 3 pulses for 3, etc. Each pulse would trigger a strowger switch at local exchange, where it would start turning a dial on the switch with an equal number of turns to the pulses or receives. For a single digit dial it would just have one switch that rotates with the number of pulses of receives. For a much more common 3-4 digit number being entered it would take the rapid succession of pulses to turn the first dial, then after a sufficient pause any subsequent pulses turn the next dial, and so on. Once it runs out of dials to turn on the switch it connects the call to the line which may go to another phone or may simply go to another strowger switch awaiting additional pulses from the user dialing additional numbers.
For example user dials 5-5-5-1-2-3 with a pause between each digit as they dial. The first 5 sends 5 pulses in quick succession to the switch the phone is directly connected to (the local exchange) and that sets the first dial on the switch to 5, the user naturally pauses for a split second creating the pause the switch interprets as a completed dial then the user enters another 5 causing another 5 pulses to go to the switch at the local exchange. After the third 5 it connects to the next exchange likely without the user even knowing and the 1 is transmitted via the local exchange to the 555 exchange where a stroger switch turns to the 1 position from the single pulse, and so on. All of the switches that connect for such a call remain engaged and connected until they receive the disconnect pulse and then they kill the connection ending the call.
With the transition to DTMF tones, much of this same behavior of each switch is just waiting for exactly how many digits it expects then connects the call to the next place remained, and with modern digital and VoIP calls, they continue to emulate the same functionality of the strowger switches, where the exchange is expecting a specific number of digits to be entered, and the user will either enter the correct number of digits or receive an error and a call that doesn’t connect. There are actually still places operating analog telephone exchanges so everything is ultimately backwards compatible, and the security and design challenges of sending signaling over the same wire as voice have remained all thanks to the cost savings choices made by some dude with an amazing mustache in the 1880s. Or we can go even further back because the telephone was actually an innovation on the telegraph, originally designed as a solution for sending multiple telegraphs over a single telegraph trunk line.
Alexander Graham Bell, a pioneering audiologist who worked with deaf kids excitedly penned a letter to an individual at the Western Union Telegraph Company describing using different tones of beeps over the line to differentiate between different telegraphs, and then excitedly went on to describe how with enough different tones one could not only transmit a nearly infinite number of different telegraphs at once but one could theoretically transmit human speech! I’ve read scans of these original letters and you can just see the excitement building as Bell described that part