A buffer contains significant amounts of both a weak acid and its conjugate base. Added $\text{H}^+$ is mopped up by the base; added $\text{OH}^-$ is neutralised by the acid. The pH therefore barely moves.
When $[\text{A}^-]=[\text{HA}]$, the log term is $0$ and pH $=$ p$K_a$. This is exactly the half-equivalence point of a titration.
Buffers work best when the ratio is near $1$, so choose an acid whose p$K_a$ is close to the target pH.
Diluting a buffer does not change its pH — the ratio stays the same.
Titration curve of a weak acid with a strong base. You must be able to read three landmarks: the flat buffer region in the middle (pH changes very slowly because both the acid and its conjugate base are present); the half-equivalence point where pH $=$ p$K_a$; and the equivalence point — note that it lies at a pH greater than $7$, not equal to $7$. The reason: by then all the acid has become its conjugate base, and that base hydrolyzes to produce $\text{OH}^-$.
Worked example: calculating the pH of a buffer
A solution contains $0.30$ M $\text{CH}_3\text{COOH}$ and $0.20$ M $\text{CH}_3\text{COONa}$. Given $K_a=1.8\times10^{-5}$. Find the pH.
The pH is slightly below p$K_a$ — reasonable, because there is more acid than conjugate base.
Quick check without a calculator: the ratio is below $1$ ⇒ the log is negative ⇒ pH must be less than p$K_a$ ✓.
Common mistake
Mixing a strong acid with a strong base does not make a buffer — it only gives a neutral salt. A buffer needs a weak conjugate pair: a weak acid together with its salt, or a weak base together with its salt.
Key takeaway
A buffer needs both a weak acid and its conjugate base. pH $=$ p$K_a$ when the ratio equals $1$. Dilution does not change the pH.