I am having trouble with how to approach this problem. I have the solution but can't figure out how to get it.

How many moles of NaOH must be added to 1.0 L of 2.0M HC2H3O2 to produce a solution buffered at each pH?
a) pH=pKa
b)pH=4
c)ph=5

You must recognize that when adding NaOH to HC2H3O2 (which is acetic acid and I will call it HAc and use Ac^- for acetate ion), you are forming a buffered solution. That means use the Henderson-Hasselbalch equation.

HAc + NaOH ==> NaAc + H2O.
moles HAc = 1.0 L x 2.0 M = 2 moles.
mols NaOH to add = ??
The HH equation is
pH = pKa + log [(base)/(acid)]
If we want pH = pKa (part a), then we want the log term to be zero, right? To be zero, the base/acid must be 1 (so that log 1 = 0. What that means is we add 1 mole NaOH to form 1 mol Ac^- and that neutralizes just half of the HAc and leaves 1 mol remaing. So the equation now is
pH = pKa + log (1/1) = pKa.

For b and c, use the same equation but plug in pH 4 or pH 5, plug in pKa for HAc, solve for (base)/(acid), then adjust NaOH to make the ratio what it needs to be.