Why doesn't knowledge of the obvious causal relationship between consciousness and brains destroy any ideas of an afterlife?

The fact that one thing causes another does not mean than the second could not exist without the first. Consider the case of a forest fire, for example. A carelessly flung match could be the cause, and yet (a) the fire could continue even after the match is destroyed, and (b) other things, such as a bolt of lightning, could substitute for the match as cause of the fire. Similarly, one could think (a) that brain activity causes consciousness, but consciousness can continue even after the brain is destroyed, or (b) that things other than brain activity, e.g. cosmic vibrations, could also cause consciousness. Without evidence to support these possibilities, they remain mere possibilities; but they do show why the causal relation you cite does not "destroy an ideas of an afterlife". If you think that an individual's consciousness is not just caused by the activity of her brain but is identical with it, then that consciousness must indeed cease when the activity of that brain ceases. But many...

Is all behaviour learned?

If you include reflex responses such as blinking one's eyes upon the approach of a fast-moving object, then the answer is clearly 'no' -- not all behavior is learned; some behavior occurs regardless of any learning. There are many sort of behavior that combine what is given and what is learned -- certain ways of walking or waving, for example There are also behaviors that are too original to rightly describe as learned. A dancer may execute a movement that has never been seen before, or a singer may make a sound that has never been heard before.