The definitive answer is that the problem is caused when Wordpress encounters an error in a theme or possibly a plugin causes such an error. WP is designed to be robust so when it encounters such an error it doesn't crash or hang, instead it stops using the theme and uses the default theme instead.
You need to remember that themes and plugins are not made by WP but are created by users. As such WP doesn't have much control over their quality (which is why it is designed to survive any such problems as described above).
If you experience this problem you can use the work-around mentioned above. You have your custom theme and your default theme but you replace the default theme files with a second copy of your custom theme. Then, when WP encounters a problem with your custom theme it will switch to the default, which is really your custom theme. Problem with this is that the error could occur again and you don't really know what will happen then.
The actual fix for the problem is to thoroughly test to find out which theme or plugin is causing the problem by removing each one and testing (possibly for long periods) and dumping the faulty one - not good if it is your favorite theme.