I suspect there are many edge cases that cause this.
It’s not just the WiFi scanning or Airplay / Touchbar. I noticed this delayed ping pattern as far back as 2016. I spent some troubleshooting time and suspected it was something in MacOS but gave up.