Example 3 Let $M=\{a, a+d, a+2 d\}, P=\left\{a, a q, a q^{2}\right\}$, where $a$ is not equal to $0, M=$ $P$, find the value of $q$.

Translate the above text into English, please retain the original text's line breaks and format, and output the translation result directly.
Given $M=P$, we have

or
$$
\begin{array}{c}
\left\{\begin{array}{l}
a+d=a q, \\
a+2 d=a q^{2},
\end{array}\right. \\
\left\{\begin{array}{l}
a+d=a q^{2}, \\
a+2 d=a q .
\end{array}\right. \\
\left\{\begin{array}{l}
a(1-q)=-d, \\
a\left(1-q^{2}\right)=-2 d .
\end{array}\right.
\end{array}
$$

From (1),

Dividing the two equations,
$$
\frac{1}{1+q}=\frac{1}{2} \Rightarrow q=1 \text { (discard). }
$$

From (2),
$$
\left\{\begin{array}{l}
a\left(1-q^{2}\right)=-d \\
a(1-q)=-2 d
\end{array}\right.
$$

Dividing the two equations,
$$
1+q=\frac{1}{2} \Rightarrow q=-\frac{1}{2}
$$

Key points for solving the problem: The distinctness and unordered nature of elements in a set are two important aspects of set characteristics. Pay attention to case analysis and verification of results when solving problems.