To address your confusion, we note that the integral test requires that $f(x)$ must be monotone decreasing over the interval $\left[1, \infty\right)$ to be applicable.
Check this link: https://en.wikipedia.org/wiki/Integral_test_for_convergence
Hence, if we have
$$f(n) = \frac{1}{n^2}$$
for all $n \in \mathbb{N}$, and you want to extend it to $\mathbb{R}$ by setting $f(x) = g(x)$ for all $x \in \mathbb{R} \setminus \mathbb{N}$, then you have to make sure that the selection of $g(x)$ keeps $f(x)$ monotone decreasing over the interval $\left[1, \infty\right)$ so that the integral test can kick in.
If the ultimate goal of extending $f(n)$ to the domain $\mathbb{R}$ as $f(x)$ is to hopefully construct $f(x)$ so that we can use the integral test to prove that the series
$$\sum_{n = 1}^{\infty} f(n) = \lim_{k \to \infty} \sum_{n = 1}^{k} f(n)$$
converges, then in this case, the way you extend $f(n)$ to $f(x)$ matters. If you can prove that there exists at least one way to extend $f(n)$ to $f(x)$ such that $f(x)$ is monotone decreasing over the interval $\left[1, \infty\right)$, then this is sufficient to invoke the integral test to prove that
$$\sum_{n = 1}^{\infty} f(n) < \infty$$
For instance, you can trivially take $g(x) = 1/x^2$ for $x \in \mathbb{R} \setminus \mathbb{N}$ so we have $f(x) = x^2$ for all $x \in \mathbb{R}$ which is monotone decreasing.
But if you just just want to know if the limit exists, then you can do so without extending $f(n)$ to $\mathbb{R}$. I mean, you can do so without invoking the integral test. Evaluating this sum is known as the Basel problem and the result is $\pi^2/6$.
Check this link: https://en.wikipedia.org/wiki/Basel_problem