For a function to be continuous at x=1, the left-hand limit must equal the right-hand limit at that point.
When approaching x=1 from the left (where x<1), the function uses f(x)=2x+1.
The left-hand limit at x=1:
x→1−limf(x)=2(1)+1
=3
When approaching x=1 from the right (where x>1), the function uses f(x)=ax−1.
The right-hand limit at x=1:
x→1+limf(x)=a(1)−1
=a−1
For continuity at x=1:
x→1−limf(x)=x→1+limf(x)
3=a−1
a=4
Therefore, a=4.