f(2)=5 f(-2)=1, I have to write the linear function for this. I got 5-1/2- -2=4/4=1 then I plugged it in so it would be y-5=1(x+2) which became y=x+7, then f(x)=x+7. The answer key, however, says f(x)=x+3. What did I do wrong?

I have no idea what you did.

y=mx+b
5=m2+b
b=5-2m
and
y=mx+b
1=m(-2)+b
b=1+2m
setting the b=b
5-2m=1+2m
4m=4
m=1
then b=5-2m or b=3
y=x+3