that is the big question, isn't it? There is a word for this, if I can remember it. Doesn't explain it, but does describe it, which is how the actions of many individuals leads to something that is more than the sum of the parts. Somehow, as a group, brain cells create something that none possess individually. like patterns formed by flocks of birds or schools of fish. Emergence, or emergent behavior, is the term. I knew if I waited it would pop up.
But how? Well, lots of ideas but none seem very good to me, but that could be because this particular brain does not have the correct emergent behavior. Who knows? Possible Nobel Prize in there for the people who figure it out, perhaps?
this gets very much into the problem of the essence of life, what is life, at the same time. Life is, on a functional process basis, just a bunch of chemical interactions, just as with non-life (although not in specific reactions), so how does it become self-aware or even if not aware, driven to self-preservation? There is more to the total than the sum of the parts.