In chemistry, a buffer solution is a solution, typically in water; It contains ions of a weak acid and its conjugate base, or a weak base and its conjugate acid. With the former, one creates an "acid buffer," and with the latter, a "base buffer". There's generally no significant difference between the two except one is acidic (pH < 7) and the other is basic (pH > 7).
The solution needs to contain ions of both a weak acid (or base) and it's conjugate base (or acid). The purpose of a buffer solution is to create a solution where adding a small amount of a strong base (or acid) will only cause a slight increase in pH. It acts as a buffer for the strong base/acid. If you have some neutral solution, or have a strong acid(base) solution, adding in a little bit of strong base(acid) will cause a HUGE change in pH. Not so for a buffer solution.
Let's take the example of a weak acid/conjugate base pair. You add in a small amount of strong base, and this strong base neutralizes a little bit of the weak acid, until what strong base you added is 'used up.' (note that 'small' is relative. if you start with, say, 50 mL of a .1 M hydrofluoric acid (HF), adding 1 mL of the strong base sodium hydroxide is considered small). This creates some more of the conjugate base. Of course, after adding in so much strong base, you can "lose" your buffer. This is observable in a titration curve, which deserves its own node entirely. Once the same number of moles of original weak acid and strong base have been added, the equivalence point is reached and the buffer is gone. (Note: you can replace all instances of base/acid in the last paragraph with acid/base).
You prepare a buffer solution by starting with a solution of weak acid or base, and adding in a salt of its conjugate base or acid. For example, if hydrofluoric acid, HF, were your weak acid, adding in a bit of, say, sodium fluoride (NaF) solution (or solid) will give you a buffer. The sodium would be a spectator, and the fluorine atoms will float around (and reach equilibrium with HF). The reason for this comes from the equilibrium expression:
HF <--> H+ + F-
Very little fluoride ion comes from the dissociation of HF, so you need to get some more fluoride ion in there to get a decent buffer. Same principle applies to pretty much every other weak acid(base)/conjugate base(acid) pair you can think of.
Something else to note is that, in general, polyprotic acids are better buffers than monoprotic ones. Just look at phosphoric acid: H3PO4. One mole of phosphoric acid can be hit with 3 moles of base before losing it's buffer (it goes to H2PO4-, HPO4-2, and PO4-3, in that order). Basically a polyprotic buffer can be hit with more moles of acid or base before being consumed entirely.