The PHP memory_limit setting applies to the maximum memory limit used by a single request, script, or process. This configuration helps prevent poorly written scripts from consuming all the available memory on a server. For instance, if three PHP scripts simultaneously use 100 MB of memory each, that would be 300 MB of memory in total, but it wouldn't hit the PHP limit of 128 MB since it applies per script.
RAM, or random access memory, is physical hardware in a computer or server. It stores data and instructions needed to run a process or script and makes them available. Basically, the system’s RAM allocates memory to these processes or scripts, as well as reserves some memory to ensure the proper function of other programs and services in the system.