When an M1-based device, such as a MacBook Pro (13-inch, M1, 2020) or MacBook Air (13-inch, M1, 2020), crashes with a flash of a pink screen, leading to a reboot, this indicates a kernel panic.
Fortunately, the issue is not hardware-based, and a Hardware Test is not necessary. It is likely that the error is reproducible with a different Mac. A kernel panic suggests that there is a bug in macOS, as all user-space exceptions should be handled properly.
You should see a "Your Mac was restarted because of a problem" screen after the machine reboots. By clicking "Send to Apple", Apple developers will be notified of the specific bug and will fix it in future versions.
In order to avoid kernel panics, use the most recent version of macOS. Specifically for your issue, it appears that the panic may have been triggered by a USB accessory such an external drive. Could you try to reproduce the panic without said accessory?