I have been dealing with this issue for months; multiple kernel panic/crashes per day any time I dock or un-dock via USB-C. I just upgraded from Big Sur to Monterey 12.1 (since Apple wouldn't open a support case for me until I did that) - and it actually hasn't had the issue since then. I have docked and undocked several times, even quickly, with no crash. So, if upgrading the OS is an option, give it a try.