In modern computers harddrives are use as memory, through what we call swapping. If the operating system requires more memory than you actually physically have installed on your computer, it will simply use part of your harddrive as memory.
This is done through something called swapping. A part of your RAM is used as swapping area. So whenever a program tries to access data in memory which isn't physically on your RAM but on your hardisk then it will cause what we call a page fault, and a chunk of data on your hardisk is pulled into this swappig area.
Afterwards the program can read that directly here.
This is the wonder of virual memory. The operating system is lying to its programs about where more actually is. It presents a virtual memory to its programs which is infinite.
Normally using virual memory and swapping to hardisk is quite slow. But SSD disks are built on very similar technology as RAM. And these SSD disks on these new M1 Macs is so fast that the swapping can be done so quickly, that from the perspective of the user it will "feel" like the whole SSD is his/her RAM.
In fact these SSD disks are likely faster than a lot of earlier generation RAM.
That is why we see 8 GB M1 Macs not loosing performance under heavy load. If you look at a system monitor you can see that under heavy load they are doing a lot of swapping, but you cannot actually feel the impact on the performance.