Example 6 Let $M=\{1,2, \cdots, 20\}, A_{1}, A_{2}, \cdots A_{n}$ be distinct non-empty subsets of $M$, such that when $i \neq j$, $A_{i} \cap A_{j}$ has at most two elements. Find the maximum value of $n$.

 untranslated text remains the same as the source text in terms of line breaks and formatting.
Solve for the number of one-element, two-element, and three-element subsets of $M$, which is $C_{20}^{1}+C_{20}^{2}+C_{20}^{3}=1350$. They satisfy the conditions of the problem, so the maximum value of $n$ is $\geqslant 1350$.

Let $B_{1}, B_{2}, \cdots, B_{n}$ be distinct non-empty subsets of $M$, such that when $i \neq j$, $\left|B_{i} \cap B_{j}\right| \leqslant 2$. If at least one of $B_{1}$, $B_{2}, \cdots, B_{n}$ has more than 3 elements, without loss of generality, assume $\left|B_{i}\right| \geqslant 4$ and $a \in B_{i}$, then $\left(B_{i} \backslash\{a\}\right) \cap B_{i}$ has at least 3 elements, so $B_{i} \backslash\left\{a \mid \notin\left\{B_{1}, B_{2}, \cdots, B_{n}\right\}\right.$ (since the intersection of any two sets in $B_{1}, B_{2}, \cdots, B_{n}$ has at most 2 elements). Now, replace $B_{i}$ with $B_{i} \backslash\{a\}$ to get a family of subsets that still meets the problem's requirements, without changing the number of subsets. Continuously perform this replacement until each subset in the family has at most 3 elements, so $n \leqslant C_{20}^{1}+C_{20}^{2}+C_{20}^{3}=1350$.
In summary, the maximum value of $n$ is 1350.