This is a broad question, asking for an overview of a whole subfield. While the answers do provide some adequate perspectives on the subject, I found them, as a whole, far less informative than the Wikipedia article on the subject. (I pick on this example because I recently learned how a particular processor implements branch prediction; the Wikipedia helped me clarify some points, whereas the CS.SE answers were not helpful.)
This site is not Wikipedia. Wikipedia does a far better job at answering the title question, how branch prediction works. The post has a second part, “Can I optimize my code to help the CPU guess more accurately?” — also too broad, as is apparent in the answers: they only provide tidbits of advice, and none of them addresses the full domain (what to do depends to some extent on the features offered by the CPU, on what the compiler can do for itself, and on what the code does).
Some sites have “general reference” as a close reason, for questions that are best looked up in a reference document (encyclopedia, dictionary, user's manual, … — this doesn't include questions where finding the reference is the main problem). This was not generally adopted, and I am not proposing it here, because there is a huge potential for abuse. Nevertheless, I propose the following guideline:
If the question boils down to “what is X”, and there is an adequate Wikipedia article (or other similar reference), then close the question. “Not a real question” is appropriate for a broad subject where we cannot be expected to write a whole précis in an answer. “Too localized” can also be used, inasmuch as looking up the obvious Wikipedia article is easier than finding the question here, so having the question here hinders future visitors more than it helps them.