Consider any of the following:
- a multi-threaded application,
- an application using shared memory,
- an application running on a platform that maps I/O registers into the address space,
- an application with hardware DMA occurring in the background.
In each of these situations, memory can be altered outside the current thread.
Note that "anytime the value of a variable is change in register, then the value should affect the memory" is correct, just not very clear.