The relationship between the brain and the mind is not fully understood. We have a lot operations understandings - specific things that we can do to the brain that can produce specific results in the mind, even very complex results in some cases. But we don't really have a good answer as to why consciousness exists at all or how the brain's operations create and maintain a state of consciousness.
We know that consciousness isn't strictly linked to memory or even to cognition, as is particularly obvious in cases of extreme mental illness impairing those things. We know that we're chalk full of reactions to stimuli, some of which are completely vestigial like the dysfunctional version of earthquake sense that doesn't work on earthquakes and mainly seems to make people have panic attacks in a certain infrasound band. We know that the brain constantly redevelops itself based on activity of use, and this is why feral or extremely abused children tend to be so screwed over and why old people descend into dementia if they don't keep themselves active.
We know that we have a lot of memory in computer terms, and that our actual memories are rewritten by the brain every time they're remembered, gradually artifacting them into obscurity. We know the brain doesn't operate on the same principles as a computer, even if there are orthogonal similarities. And we certainly know that simplistic evopsych analytics do not explain the wholeness of human behavior, which is often consistent but yet sometimes radically strikes out and defies predictions, even though we also know there is very little likelihood anything like free will actually exists.