It’s all about frequency response and filtering.
The scheme you describe is called “pulse width modulation”, and it works how you describe. For a given time period, the signal is pulsed on and off so the average amount of time that it is on is equal to the output value that you want.
Now you need a filter – specifically a low-pass filter. For dimming LEDs, our eyes do it – we interpret the PWM signal as the average value.
In other cases, it is done electronically.
There’s a very popular class of audio amplifier known as “class D” that uses this technique, and it makes light and powerful amplifiers.
Note that there are also a wide range of digital to analog converters that produce true analog output.
Latest Answers