Each piece is continuous on the interior of its own interval, so only x=1 and x=2 need checking.
At x=1.
x→1−limf(x)=a1,f(1)=a
a1=a⟹a2=1⟹a=±1
At x=2.
x→2−limf(x)=a,f(2)=22b2−4b=b2−2b
b2−2b=a
Case a=1. Then b2−2b−1=0, so
b=22±4+4=1±2
Case a=−1. Then b2−2b+1=0, i.e. (b−1)2=0, so
b=1
Answer.
a=1, b=1±2ora=−1, b=1
Check for a=−1,b=1. The three pieces become −x2, −1 and x2−2. At x=1: −1=−1. At x=2: −1=2−2=−1. ✓
Note that a=0 is impossible — the first piece would be undefined — which is why dividing by a at the first step was safe.