Both UPS and speaker end up having the same electrical hum, how come?
Load waveform in audacity, normalize. Buzz is present at the beginning and absent at the end, allowing comparison. There is a buzz signal around 5k with harmonics, and 50Hz hum. FFT on a representative interval:
Buzz absent: 50Hz -37dB
Buzz present: 50Hz -37dB
Therefore 50Hz hum is probably from the microphone and irrelevant to the problem. I remove it by applying 500Hz highpass filter to the whole waveform. Result:


-&gt; Peak around 5500 Hz plus harmonics.
Clues from waveform:

No change across the recording, stops abruptly

5k buzz present with duty cycle about 60%, absent in rest of half cycle


These two are in contradiction. The duty cycle would mean a phase cut dimmer or something that is modulated on AC cycle, with a noise generator downstream. For example a triac dimmer and a bulb with a noisy switching driver. But the latter would run at a much higher frequency than 5 kHz. And the 5kHz frequency indicates something heavy, like a motor VFD, for example in the elevator. But it stops abruptly at the end, which means it's probably not a heavy motor VFD like the building elevator.
If you had a recording of when the buzz starts, that would give more information.
Here's what I'm thinking about to explain both the 5k frequency and the 100Hz modulation:
Faulty LED/CFL bulb or electronic ballast with a switching supply that hiccups at 5kHz, coupled with a triac dimmer.
Or a motor VFD that runs at a low switching frequency, maybe an inverter fridge or heat pump.
Or the offending device is powered from three phase AC to DC rectifier without power factor correction, and only pushes noise into the phase powering your appartment when corresponding diodes conduct.
You could pick up the Logitech speakers and plug them into the wall socket closest to the main electrical panel, then flip all the breakers one by one until you no longer hear it.
EDIT from your recording of when it starts:

So, it starts abruptly, and then the noise pattern remains the same, which means it's probably not a motor. The noise pattern would change as the motor accelerates.
Note your first signal (top) is slightly different from your latest upload: