For a function to be continuous at x=2, the values of the function must be equal from both sides at that point. The equation 5(2)-1 = a(2)^2+1 is used to find the value of 'a' that ensures this continuity. Solving this equation yields a = 2, which is the necessary value for continuity. The intuition behind this is that continuity requires the left-hand limit and right-hand limit to match the function's value at that point. Thus, determining 'a' ensures the function behaves consistently at x=2.