The LaTeX kernel borrows its definition of \pmod
\def\pmod#1{%
\allowbreak\mkern18mu({\operator@font mod}\,\,#1)}
(see ltmath.dtx, code lines 39–40) from plain TeX, in which it reads
\def\pmod#1{\allowbreak\mkern18mu({\rm mod}\,\,#1)}
(see The TeXbook, p. 361); in both cases, the space that precedes the word “mod” is 1em wide. The examples of use given on p. 164 of The TeXbook, as well as the answer to Exercise 18.4, show that Knuth intended that that amount of space ought to be used also in in-line math formulas. Nonetheless, the amsmath package modifies the above definition in such a way that a narrower space is employed when the formula is “not displayed”:
\newcommand{\pod}[1]{\allowbreak
\if@display\mkern18mu\else\mkern8mu\fi(#1)}
\renewcommand{\pmod}[1]{\pod{{\operator@font mod}\mkern6mu#1}}
(see also this answer to Writing mod in congruence problems without leading space, a question already linked from the accepted answer to this question). As you can see, the condition of “not being in display” is detected through the \if@display switch.
Musing over this question, I began to wonder whether this could be a bug—or rather, a design flaw—in the package. Perhaps a better idea would be to have the amount of space change with the current math style, in a fashion similar to the way in which “big operator” symbols like \sum or \int change their size (and, to some extent, their shape) between display and non-display math. This behavior is easily achieved with the patch to the \pod command (defined by the amsmath package) that the following code shows:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
% \usepackage{amsmath} % Required for what follows; but...
\usepackage{mathtools} % ... "mathtools" automatically loads "amsmath".
\makeatletter
\renewcommand*\pod[1]{%
\allowbreak
\mathchoice
{\mkern 18mu}%
{\mkern 8mu}%
{\mkern 8mu}%
{\mkern 8mu}%
(#1)%
}
\makeatother
\newtheorem{thm}{Theorem}
\begin{document}
In-line: \( 5\equiv 1 \pmod 4 \). In display:
\[ 5\equiv 1 \pmod 4 \]
Non-display inside display:
\[
f(x) =
\begin{cases}
4 & \mbox{if $x\equiv 0 \pmod 4$,} \\
x\bmod 4 & \mbox{otherwise.}
\end{cases}
\]
The same thing, but with \texttt{cases*} (requires \textsf{mathtools}):
\[
f(x) =
\begin{cases*}
4 & if $x\equiv 0 \pmod 4$, \\
x\bmod 4 & otherwise.
\end{cases*}
\]
\begin{thm}
All over again.
In-line: \( 5\equiv 1 \pmod 4 \). In display:
\[ 5\equiv 1 \pmod 4 \]
Non-display inside display:
\[
f(x) =
\begin{cases}
4 & \mbox{if $x\equiv 0 \pmod 4$,} \\
x\bmod 4 & \mbox{otherwise.}
\end{cases}
\]
With \texttt{cases*}:
\[
f(x) =
\begin{cases*}
4 & if $x\equiv 0 \pmod 4$, \\
x\bmod 4 & otherwise.
\end{cases*}
\]
\end{thm}
Nonetheless, inside an alignment, say
\begin{align*}
2 &\equiv 9 \pmod 7 \\
4 &\equiv 1 \pmod 3 \mbox{,}
\end{align*}
the output agrees with that of a displayed equation:
\[
5\equiv 1 \pmod 4 \mbox{.}
\]
\end{document}
This is the output the above code yields:

This modification could be an elegant and consistent way of achieving what the question asks for. If the \mod command is used as well, it should be similarly modified too. Of course, one can’t introduce these changes in the code of masmath package without disrupting all existing documents that use these features…
Addition:
Continuing to chew over this issue, I thought that it could even make sense to use the \pmod command in super/subscripts (see example below); and in this case, it seems that the space before the left parenthesis should be made even thinner.
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
% \usepackage{amsmath} % Required for what follows; but...
\usepackage{mathtools} % ... "mathtools" automatically loads "amsmath".
\makeatletter
\renewcommand*\pod[1]{%
\allowbreak
\mathchoice
{\mkern 18mu}%
{\mkern 8mu}%
{\mkern 6mu}% "6mu" matches the space *after* the word "mod"
{\mkern 6mu}%
(#1)%
}
\makeatother
\newtheorem{thm}{Theorem}
\begin{document}
In-line: \( 5\equiv 1 \pmod{4} \). In display:
\[ 5\equiv 1 \pmod{4} \]
Non-display inside display:
\[
f(x) =
\begin{cases}
4 & \mbox{if $x\equiv 0 \pmod{4}$,} \\
x\bmod 4 & \mbox{otherwise.}
\end{cases}
\]
The same thing, but with \texttt{cases*} (requires \textsf{mathtools}):
\[
f(x) =
\begin{cases*}
4 & if $x\equiv 0 \pmod{4}$, \\
x\bmod 4 & otherwise.
\end{cases*}
\]
\begin{thm}
All over again.
In-line: \( 5\equiv 1 \pmod{4} \). In display:
\[ 5\equiv 1 \pmod{4} \]
Non-display inside display:
\[
f(x) =
\begin{cases}
4 & \mbox{if $x\equiv 0 \pmod{4}$,} \\
x\bmod 4 & \mbox{otherwise.}
\end{cases}
\]
With \texttt{cases*}:
\[
f(x) =
\begin{cases*}
4 & if $x\equiv 0 \pmod{4}$, \\
x\bmod 4 & otherwise.
\end{cases*}
\]
\end{thm}
Nonetheless, inside an alignment, say
\begin{align*}
2 &\equiv 9 \pmod{7} \\
4 &\equiv 1 \pmod{3} \mbox{,}
\end{align*}
the output agrees with that of a displayed equation:
\[
5\equiv 1 \pmod{4} \mbox{.}
\]
In super\slash subscripts:
\[
\int_{0}^{3\pi} \sin x\,dx
= -\cos x \biggr|_{0}^{3\pi}
= -\cos x \biggr|_{x\equiv 0 \pmod{2\pi}}^{x\equiv 3\pi \pmod{2\pi}}
= -\cos x \biggr|_{0}^{\pi}
= 1-(-1) = 2
\]
\end{document}
The output in this second case is

eqnarray*which produces bad spacing at the alignment points. Use one of theamsmathenvironments instead (align*oralignat*). – Bernard Aug 14 '19 at 09:24