Several files in the /etc directory are changed by startup script programs such as
"/etc/rc.d/rc.sysinit" and the script programs in /etc/rc.d/init.d/. Certain scripts in this directory are run based on the runlevel the system is changing to.
The /etc/HOSTNAME file is changed in the /etc/rc.d/rc.sysinit script program. The value it is changed to is based on the /etc/sysconfig/network file. Learning about the files in /etc/sysconfig will help you understand how your system is configured.
If you are interested in learning about how your system starts and why it may change certain files you may want to read the material at:
http://ctdp.tripod.com/os/linux/index.html
The "How Linux Works" and "Startup Manual" should be of some help. Section 14 of "How Linux Works" should help you understand system configuration issues.
I hope this helps.