When Macaulay 2 is successfully installed, its files are installed in a directory tree whose layout, relative to the root, is determined by the hash table LAYOUT. When M2 starts up, it detects whether it is running in such a layout, and sets prefixDirectory to the root of that directory tree. The way it does that is that it locates the running M2 executable and determines whether it is located in a directory whose name is bin that has a sibling directory called share that leads to a directory called share/Macaulay2/Core/.
The prefix directory can be set at an early stage when M2 starts up with the --prefix command line option.
The object prefixDirectory is null.