A solution with the tabularray
package:
\documentclass{beamer}
\usepackage{tabularray}
\begin{document}
\frame{
\begin{tblr}{
colspec = { *{3}{c }},
hline{1} = {1}{2-3}{},
hline{2,4} = {1}{1-3}{},
hline{3} = {1}{1-2}{rightpos = 0},
hline{3} = {2}{1-2}{},
vline{1} = {1}{2-3}{},
vline{2} = {1}{1-3}{},
vline{3} = {1}{1-2}{},
vline{3} = {2}{1-2}{belowpos = 1},
vline{4} = {1}{1-3}{belowpos = 1},
}
& $M_2$ & $a$ \\
$M_1$ & $M_3$ & \\
$b$ & & $x$ \\
\end{tblr}
}
\end{document}
If you want to get a continuous gap also between the vertical lines on the right side, it might be better to use the nicematrix
package, which combines the strengths of TikZ with the possibilities of tabulars (at least tabularray
won't give you a nice result in this case):
\documentclass{beamer}
\usepackage{nicematrix, tikz}
\begin{document}
\frame{
\begin{NiceTabular}{ *{3}{c} }
& $M_2$ & $a$ \\
$M_1$ & $M_3$ & \\
$b$ & & $x$ \\
\CodeAfter
\begin{tikzpicture}
\draw
(1-|2) --
([xshift=-1pt]1-|3) --
([xshift=-1pt, yshift=1pt]3-|3) --
([yshift=1pt]3-|1) --
(2-|1) -- (2-|2) -- cycle;
\draw
([xshift=1pt]1-|3) --
(1-|4) -- (4-|4) -- (4-|1) --
([yshift=-1pt]3-|1) --
([xshift=1pt, yshift=-1pt]3-|3) --
cycle;
\draw (2-|2) -- ([xshift=-1pt]2-|3)
([xshift=1pt]2-|3) -- (2-|4);
\draw (2-|2) -- ([yshift=1pt]3-|2)
([yshift=-1pt]3-|2) -- (4-|2);
\end{tikzpicture}
\end{NiceTabular}
}
\end{document}