Four. (30 points) As shown in Figure 4, $M$ is the midpoint of the median $AD$ of $\triangle ABC$, and a line through $M$ intersects sides $AB$ and $AC$ at points $P$ and $Q$ respectively.
Let $\overrightarrow{AP} = x \overrightarrow{AB}, \overrightarrow{AQ} = y \overrightarrow{AC}$, and denote $y = f(x)$.
(1) Find the expression for the function $y = f(x)$;
(2) Let $g(x) = x^3 + 3a^2 x + 2a$ for $x \in [0, 1]$.
If for any $x_1 \in \left[\frac{1}{3}, 1\right]$, there always exists $x_2 \in [0, 1]$ such that $f(x_1) = g(x_2)$, find the range of the real number $a$.
(1) Since the line passing through point $M$ intersects sides $A B$ and $A C$, we have $x>0, y>0$.
Thus, $\overrightarrow{A B}=\frac{1}{x} \overrightarrow{A P}, \overrightarrow{A C}=\frac{1}{y} \overrightarrow{A Q}$.
Therefore, $\overrightarrow{A M}=\frac{1}{2} \overrightarrow{A D}=\frac{1}{4}(\overrightarrow{A B}+\overrightarrow{A C})$
$$
=\frac{1}{4 x} \overrightarrow{A P}+\frac{1}{4 y} \overrightarrow{A Q} \text {. }
$$

Since points $P, M, Q$ are collinear, we have
$$
\frac{1}{4 x}+\frac{1}{4 y}=1 \text {, }
$$

which gives $f(x)=y=\frac{x}{4 x-1}$.
From $0<y \leqslant 1$, we get $0<\frac{x}{4 x-1} \leqslant 1$.
Solving this, we find $x \geqslant \frac{1}{3}$.
Thus, $y=f(x)=\frac{x}{4 x-1}\left(x \in\left[\frac{1}{3}, 1\right]\right)$.
(2) Since $g^{\prime}(x)=3 x^{2}+3 a^{2} \geqslant 0$, we know that $g(x)$ is an increasing function on $[0,1]$. Therefore,
$$
\begin{array}{l}
g(x)_{\text {min }}=g(0)=2 a, \\
g(x)_{\max }=g(1)=3 a^{2}+2 a+1 .
\end{array}
$$

Hence, the range of function $g(x)$ is $\left[2 a, 3 a^{2}+2 a+1\right]$.
Since $f(x)=\frac{x}{4 x-1}=\frac{1}{4}+\frac{\frac{1}{4}}{4 x-1}$ is a decreasing function on $\left[\frac{1}{3}, 1\right]$, we have
$$
\begin{array}{l}
f(x)_{\min }=f(1)=\frac{1}{3}, \\
f(x)_{\max }=f\left(\frac{1}{3}\right)=1 .
\end{array}
$$

Thus, the range of function $f(x)$ is $\left[\frac{1}{3}, 1\right]$.
By the problem statement, $\left[\frac{1}{3}, 1\right] \subseteq\left[2 a, 3 a^{2}+2 a+1\right]$.
Therefore, $\left\{\begin{array}{l}2 a \leqslant \frac{1}{3}, \\ 3 a^{2}+2 a+1 \geqslant 1 \text {. }\end{array}\right.$
Solving this, we find the range of $a$ to be
$$
\left(-\infty,-\frac{2}{3}\right] \cup\left[0, \frac{1}{6}\right] \text {. }
$$