Example 4 Let $f(x)$ be a function defined on the interval $(-\infty,+\infty)$ with a period of 2. For $k \in \mathbb{Z}$, let $I_{k}$ denote the interval $(2 k-1,2 k+1]$. It is known that when $x \in I_{0}$, $f(x)=x^{2}$.
(1) Find the analytical expression of $f(x)$ on $I_{k}$;
(2) For natural numbers $k$, find the set $M_{k}=\left\{a \mid\right.$ such that the equation $f(x)=a x$ has two distinct real roots in $\left(I_{k}\right)$}.
Solution: (1) From the given, we have $f(x-2k) = f(x), k \in \mathbb{Z}$.
Since when $x \in I_{k} = (2k-1, 2k+1]$, $x-2k \in I_{0} = (-1, 1]$, and when $x \in I_{0}$, we have $f(x) = x^2$, thus, $f(x-2k) = (x-2k)^2, x \in I_{k}, k \in \mathbb{Z}$.
(2) When $k \in \mathbb{N}$ and $x \in I_{k}$, from (1), the set $M_{k}$ we are looking for is the set of $a$ such that the equation $(x-2k)^2 = ax$ has two distinct real roots in $(2k-1, 2k+1] (k \in \mathbb{N})$. The equation $(x-2k)^2 = ak$ can be rewritten as $x^2 - (4k + a)x + 4k^2 = 0$. The necessary and sufficient condition for this equation to have two distinct real roots in the interval $I_{k} (k \in \mathbb{N})$ is that $a$ satisfies
$$
\left\{\begin{array}{l}
\Delta = (4k + a)^2 - 16k^2 = a(a + 8k) > 0 \\
\frac{1}{2}[4k + a - \sqrt{a(a + 8k)}] > 2k - 1 \\
\frac{1}{2}[4k + a + \sqrt{a(a + 8k)}] \leq 2k + 1
\end{array}\right.
$$

Simplifying, we get
$$
\left\{\begin{array}{l}
a(a + 8k) > 0 \\
\sqrt{a(a + 8k)} < 2 - a
\end{array}\right.
$$

When $a > 0$, $2 + a > 2 - a$, then from (2) and (3), we have $\sqrt{a(a + 8k)} \leq 2 - a$, i.e.,
$$
\left\{\begin{array}{l}
a(a + 8k) \leq (2 - a)^2 \\
2 - a > 0
\end{array}\right.
$$
Solving, we get $0 < a \leq \frac{1}{2k + 1}$.
When $a < -8k$, $2 + a < 2 - 8k < 0$, the inequality $\sqrt{a(a + 8k)} < 2 + a$ has no solution.

In summary, $a$ satisfies $0 < a \leq \frac{1}{2k + 1}$. Therefore, the set we are looking for is $M_{k} = \{a \mid 0 < a \leq \frac{1}{2k + 1}, k \in \mathbb{N}\}$.

Explanation: The necessary and sufficient condition for the equation $(x-2k)^2 = ax$ to have two distinct real roots in the interval $(2k-1, 2k+1] (k \in \mathbb{N})$ is that the graphs of the functions $f(x) = (x-2k)^2, x \in I_{k}, k \in \mathbb{N}$ and $g(x) = ax$ intersect at two different points.

It is easy to see that the condition $a$ must satisfy is that the slope $a$ of the line $y = ax$ satisfies $0 < a \leq \frac{1}{2k + 1}, k \in \mathbb{N}$.