Does the brain always think of an appropriate response when reacting to a stimulus?
Well, not always but most of the time; reacting to stimuli is what defines the nervous system and the part of the nervous system that includes the brain is called the 'central nervous system' or CNS. Reactions to stimuli (nerve impulses) don't always have to pass through the brain as the CNS consists of the brain and the spinal cord. This means that in the case of thinking, if what you see (or sense) is something harmful (a man with a knife, feel extreme heat) then you will react without the nerve impulse having to pass through your brain (instead it will simply pass through your spinal cord). This is because the body does not need nor want to waste time thinking about an obvious and protective response. This reaction that requires no conscious thinking is called a 'reflex reaction' or an 'automatic reaction'. If you want to know more about this you should probably look into the nervous system.