My system freezes randomly

Appears to be related to your storage device. Firstly, check if you’re impacted by "PSA: Linux 5.16 has major regression in btrfs causing extreme IO load", second you really should update your kernel as there are many fixes in between 5.16.1 and 5.16.4.

If you can’t update 5.16 then use 5.15 and see if that works better.