Without expansion of \a and with \meaning:
\documentclass{article}
\begin{document}
\def\z{12pt}%
\def\a{\noindent\fontsize{10pt}{\z}\selectfont}%
\makeatletter
\edef\b{\expandafter\strip@prefix\meaning\a}
\makeatother
\texttt{\b}
\end{document}

The spaces after command names are inserted by TeX.
Variant with e-TeX's \detokenize:
\edef\b{\detokenize\expandafter{\a}}
In both cases, the tokens in the definition text of \b have category code 12 (other) and the space has category code 10 (space).
If the contents of \a is more or less known, then the macros that should not be expanded can be prevented from expansion by redefining them to the meaning of \relax:
\documentclass{article}
\begin{document}
\def\z{12pt}%
\def\a{\noindent\fontsize{10pt}{\z}\selectfont}%
\begingroup
\let\fontsize\relax
\let\selectfont\relax
\edef\x{\a}
\xdef\b{\detokenize\expandafter{\x}}
\endgroup
\texttt{\b}
\end{document}

A full expansion of \a only works for some macros with more or less useful result:
\documentclass{article}
\begin{document}
\def\z{12pt}%
\def\a{\noindent\fontsize{10pt}{\z}\selectfont}%
\edef\tmp{\a}
\edef\b{\detokenize\expandafter{\tmp}}
\endgroup
\texttt{\b}
\end{document}

Adding package microtype, for example, will get a macro \a that breaks in a hard expansion by \edef:
! Argument of \MT@res@a has an extra }.
<inserted text>
\par
l.7 \edef\tmp{\a}
LaTeX's protection mechanism can be used by the softer \protected@edef. Then, commands defined by \DeclareRobustCommands and commands with optional arguments are not expanded too much:
\documentclass{article}
\usepackage{microtype}
\begin{document}
\def\z{12pt}%
\def\a{\noindent\fontsize{10pt}{\z}\selectfont}%
\makeatletter
\protected@edef\tmp{\a}
\makeatother
\edef\b{\detokenize\expandafter{\tmp}}
\texttt{\b}
\end{document}

\bknow that it should expand\zbut not\fontsizeand\selectfont? – Heiko Oberdiek Aug 05 '17 at 09:21\bexpands everything recursively until it can't anymore. – Evan Aad Aug 05 '17 at 09:22