This article contains the following formula for the spherical harmonics: $$Y_l^m(\theta,\phi) = \sqrt{\frac{(2l+1)}{4\pi}\frac{(l-m)!}{(l+m)!}} P_l^m(\cos \theta) e^{im\phi}$$ Now let $S$ be the unit sphere in three dimensions. Clearly, the function\begin{align}F\colon\mathbb R\times\mathbb R&\to S\\(\theta,\phi)&\mapsto\begin{pmatrix}\sin\theta\cos\phi\\\sin\theta\sin\phi\\\cos\theta\end{pmatrix}\end{align} to the sphere is surjective, but it is necessary that $F(\theta,\phi)=F(x,y)$ implies that $Y(\theta,\phi)=Y(x,y)$ so that we can define $Y$ on $S$.
For example, consider the north pole $N=(0,0,1)$. Clearly, $F(0,\phi)=N$ for all $\phi\in\mathbb R$, but in general the function $$\mathbb R\ni\phi\mapsto Y(0,\phi)$$is not constant, is it?