Example 2 Given the function $f(x)=\lg \left[\left(a^{2}-1\right) x^{2}+(a+1) x+1\right]$.
(1) If the domain of $f(x)$ is $\mathbf{R}$, find the range of values for $a$;
(2) If the range of $f(x)$ is $\mathbf{R}$, find the range of values for $a$.
Solve (1) The domain of $f(x)$ is $\mathbf{R} \Leftrightarrow\left(a^{2}-1\right) x^{2}+(a+1) x+1>0$ always holds,
then $\left\{\begin{array}{l}a^{2}-1>0, \\ \Delta=(a+1)^{2}-4\left(a^{2}-1\right)0, \\
\Delta=(a+1)^{2}-4\left(a^{2}-1\right) \geqslant 0
\end{array} \Leftrightarrow a \in\left(1, \frac{5}{3}\right],\right.
$

or
$a^{2}-1=0$, upon inspection, $a=1$ satisfies the condition.
Therefore, $a \in\left[1, \frac{5}{3}\right]$.
Solution Guidance: Equivalent transformation is an effective approach to solving problems. Here, the given condition of the problem is changed: the domain is changed to the range, which completely alters the requirement for the argument. When finding the domain, the argument must be greater than zero; when the range is $\mathbf{R}$, the argument must take all values greater than zero. The solution relies on equivalent transformation.