Fine math typography prescribes a thin space in order to separate a function from a differential.
The \mathop{} bit does this, because when a \mathop follows an ordinary atom or a closing atom, TeX will add a thin space between them.
Such a thin space will not be added if \mathop is preceded by an operation symbol, like in \dd x+\dd y: only the automatic space surrounding + would be used.
The problem with the definition you found is that there is too much space: indeed, \mathop{} also inserts a thin space if followed by an ordinary atom (your \mathrm{d}), and you add another one.
You should instead remove the automatically added space.
\documentclass{article}
\newcommand{\ddbad}{\mathop{}\,\mathrm{d}}
\newcommand{\ddgood}{\mathop{}\!\mathrm{d}}
\begin{document}
\[
\int f(x)\ddbad x \qquad \int f(x)\ddgood x
\]
\end{document}

With \ddbad you get three thin spaces, one before \mathop{} and two after it. With \ddgood there is just one thin space, because \! cancels out the one automatically inserted after \mathop{}.
If you try and typeset
\[
\ddbad x+\ddbad y \qquad \ddgood x+\ddgood y
\]
you'll see more clearly what goes wrong.

\mathopwill insert extra space if the\ddis preceded by a math atom. – Steven B. Segletes Jan 07 '20 at 13:40\mathopbut of the\,command actually – Hoang Nam Jan 07 '20 at 13:43\,is even needed here. The\mathop{}will add the space. – daleif Jan 07 '20 at 13:44\mathop{}\!\mathrm{d}. Where did you find the version with\,? – egreg Jan 07 '20 at 13:45\!,dxwill be stick with f(x) if I usef(x)\ddx, it is not good at all – Hoang Nam Jan 07 '20 at 13:49