I am confused about the regularity theorem for Laplacian. It states that if we take a weak solutions of $\Delta u = \lambda u$, then $u$ must be a smooth function. But I cannot understand this statement in the following example:
Consider two domains: $\Omega_1 = \{0 \leqslant x, y \leqslant 1\}$, and $\Omega_2 = \{1 \leqslant x \leqslant 2, 0 \leqslant y \leqslant 1\}$. Consider the functions $u_1(x,y) = \sin \pi x \sin \pi y$ and $u_2(x,y) = - \sin \pi x \sin \pi y$. They are both eigenfunctions of Laplacian on $\Omega_1$ and $\Omega_2$ with eigenvalue $2$.
Let's construct a function $u$ on $\Omega_1 \cup \Omega_2$
$u(x,y) = \begin{cases} u_1(x,y), \ (x,y) \in \Omega_1 \\ u_2(x,y), \ (x,y) \in \Omega_2\end{cases} $
This function is continuous on $\Omega_1 \cup \Omega_2$ and has first derivatives everywhere except for $\{(x,y) | x = 1\}$. This function is also a weak solution on $\Omega$. So, by the ergularity theorem, it must be smooth. But it is not. What am I missing?
Your $u$ is NOT a weak solution. First of all, it is direct to show that $$\partial_x^2u_1(x,y)=-\pi^2\sin\pi x\sin\pi y=-\pi^2 u_1(x,y)=\partial_y^2u_1(x,y)\Longrightarrow\Delta u_1=-2\pi^2 u_1, $$ and similarly for $u_2$, hence $\lambda=-2\pi^2$ (NOT $2$ as in OP).
$u$ is a weak solution to $\Delta u=\lambda u$ if and only if $$\int_\Omega \nabla u(x,y)\cdot \nabla\phi(x,y)+\lambda u(x,y)\phi(x,y)\,dxdy=0$$ for all $\phi\in C_c^\infty(\Omega)$. Now take an arbitrary $\phi\in C_c^\infty(\Omega)$, we have $$\int_0^1\partial_xu(x,y)\partial_x\phi(x,y)\,dx=\partial_xu_1(1,y)\phi(1,y)-\int_0^1 \partial_x^2u_1(x,y)\phi(x,y)\,dx, \qquad y\in[0,1],$$ hence $$\int_0^1\int_0^1\partial_xu(x,y)\partial_x\phi(x,y)\,dxdy=\int_0^1\partial_xu_1(1,y)\phi(1,y)\,dy-\int_0^1\int_0^1 \partial_x^2u_1(x,y)\phi(x,y)\,dxdy.$$ Similarly we have $$\int_0^1\int_0^1\partial_yu(x,y)\partial_y\phi(x,y)\,dxdy=-\int_0^1\int_0^1 \partial_y^2u_1(x,y)\phi(x,y)\,dxdy,$$ hence \begin{align*} \int_0^1\int_0^1\nabla u(x,y)\cdot \nabla\phi(x,y)\,dxdy&=\int_0^1\partial_xu_1(1,y)\phi(1,y)\,dy-\int_0^1\int_0^1\Delta u_1(x,y)\phi(x,y)\,dxdy\\ &=-\pi\int_0^1\sin(\pi y)\phi(1,y)\,dy-\lambda\int_0^1\int_0^1 u_1(x,y)\phi(x,y)\,dxdy. \end{align*} Similarly, \begin{align*} \int_1^2\int_0^1\nabla u(x,y)\cdot \nabla\phi(x,y)\,dxdy&=-\int_0^1\partial_xu_2(1,y)\phi(1,y)\,dy-\int_1^2\int_0^1\Delta u_2(x,y)\phi(x,y)\,dxdy\\ &=-\pi\int_0^1\sin(\pi y)\phi(1,y)\,dy-\lambda\int_1^2\int_0^1 u_2(x,y)\phi(x,y)\,dxdy. \end{align*} Hence $$\int_\Omega \nabla u(x,y)\cdot \nabla\phi(x,y)+\lambda u(x,y)\phi(x,y)\,dxdy=-2\pi\int_0^1\sin(\pi y)\phi(1,y)\,dy.$$ Taking $\phi\in C_c^\infty(\Omega)$ such that $\int_0^1\sin(\pi y)\phi(1,y)\,dy\neq0$ shows that $u$ is NOT a weak solution to $\Delta u=\lambda u$ in $\Omega$.