What are the physical processes underlying all this? The brain is a strange place...
Our brains tell us we’ve Done Something Before We Actually Do It http://blogs.discovermagazine.com/d-brief/2019/04/24/action-perception-basketball/. This is a crucial factor in generating our attitudes and bias - our pre-existing state of mind is directly determining how we respond because it generates perspectives and expectations based on prior experience and existing character.
Confirmation bias is driven by varying levels of attention? So you attend to information that triggers your existing perception and expectations https://medium.com/proceedings-of-the-national-academy-of-sciences/attention-may-be-at-the-root-of-confirmation-bias-57276261bf4f
Predicting the future https://www.quantamagazine.org/to-make-sense-of-the-present-brains-may-predict-the-future-20180710/. In this context, consistency helps make predictions - uncertainty makes predictions harder and therefore may generate anxiety.
How does this fit in? <Dreams https://www.nbcnews.com/better/pop-culture/your-weird-dreams-actually-make-lot-sense-according-neuroscience-psychology-ncna913436 So your brain needs a story or episodic process to think and create memories. When you're asleep it creates these as semi-conscious dreams. The dream may be linked to the issue at hand or only vaguely, eg emotional verses physical similarity.>
Learning https://www.sciencedirect.com/science/article/abs/pii/S0959438817301587?via%3Dihub role of dopamine in learning and action https://royalsocietypublishing.org/doi/10.1098/rspb.2018.1645 ditto Role of time https://www.quantamagazine.org/how-the-brain-creates-a-timeline-of-the-past-20190212/
Brains are social things - we are not isolated individuals with no connections to others. Our social lives have a big impact upon our sense of self and character. https://theconversation.com/how-the-brain-builds-a-sense-of-self-from-the-people-around-us-new-research-141844.
Revenge sleep procrastination is an emerging phenomenon whereby an unconscious desire to regain free time leads to a resistance to going to sleep. Another instance of a somewhat broken attempt to 'take back control'. https://www.frontiersin.org/articles/10.3389/fpsyg.2014.00611/full https://greatist.com/discover/revenge-bedtime-procrastination