My non-expert opinion is that it is a software issue, because from my own observations, I can get my connection speed on the 5Ghz network to run at the maximum and have 10-15ms ping times by disabling AWDL in the Terminal or not accessing features that use AWDL (such as AirDrop, Sidecar etc.). As soon as AWDL becomes active again and I use AirDrop for example, my connection cuts out and Ping times spike dramatically.
It does seem to be affecting M1/M2 Macs more recently, but maybe that's just a side effect of them having been selling more lately, rather than it affecting that hardware specifically.
I'm going to see if I can try a different router that's compatible with my fibre connection. The router I've got is Wi-Fi 6 (802.11ax), so I'll try an older one 802.11ac to see if it makes any difference whatsoever.