Hi--
I don't have the definitive answer, but I believe that I can help you. I've had my iTunes library on a WD MyCloud PR4100 for about six years now, most of which has worked as intended.
When you open iTunes (or in the process of using iTunes), it immediately (or continuously) is searching for the active iTunes library file using the directory reference you've saved in Preferences. If iTunes cannot locate or access this library, then it creates an instance of a library on your (typically) C:\ drive. The next time you open iTunes, the application will go to this different file location of the library until you visit preferences to return it to your other location.
The only way I know to defeat it is to ensure that your library file is fully accessible to iTunes when iTunes is attempting to access the library. If you're storing on a local hard drive, then that shouldn't be an issue. If you're storing on a NAS, then your connection to the NAS must be good.