When you do \newenvironment, the category code of ^ is 7 and this is not changed by \catcode`^=\active.
\begingroup
\catcode`^=\active
\gdef\changehat{\def^{\mathchar\numexpr"7000+`\^\relax}}
\endgroup
\newenvironment{wse}
{%
\catcode`^=\active
\changehat
$%
}
{%
$%
}
Full example
\documentclass{article}
\begingroup
\catcode`^=\active
\gdef\changehat{\def^{\mathchar\numexpr"7000+`\^\relax}}
\endgroup
\newenvironment{wse}
{%
\catcode`^=\active
\changehat
$%
}
{%
$%
}
\begin{document}
X$a^b$X\begin{wse}a^b\end{wse}X
\end{document}

An alternative with the \lowercase trick that assumes ~ is active.
\documentclass{article}
\newenvironment{wse}
{%
\catcode`^=\active
\begingroup\lccode`~=`\^ \lowercase{\endgroup
\def~{\mathchar\numexpr"7000+`\^\relax}}%
$%
}
{%
$%
}
\begin{document}
X$a^b$X\begin{wse}a^b\end{wse}X
\end{document}
\defonly stores character tokens with the category code they have at the moment the definition is made and that\defdoes no interpretation whatsoever of the tokens in the body. The above indirect method is one of the tricks to use; there exist variations on the theme, I showed also one of them. – egreg Sep 22 '17 at 20:57\changehatoutside of the environment (eg just after the\endgroup. Is this incorrect, or is there any reason to prefer placing it in the environment? – JeanPierre Feb 11 '21 at 20:22^at definition time. – egreg Feb 11 '21 at 20:30^active everywhere, with the impossibility of using it for superscripts. – egreg Feb 11 '21 at 20:35^in different environments. – egreg Feb 11 '21 at 20:51