As Ulrike and Enrico have already pointed out in comments, (a) the punctuation characters do go inside the display math group and (b) it's much better to write \[ ... \] rather than $$ ... $$ in a LaTeX document.
If, however, you can't break either habit, and if you're able to use LuaLaTeX, the following solution may be what you're looking for. The solution, as shown below, currently works for only two punctuation characters, viz., , (comma) and . (period, aka "full stop"); however, it's straightforward to extend it to handle additional punctuation characters, such as ; and :. Furthermore, do observe that the code (a) automatically inserts a thinspace before the punctuation characters, (b) places the punctuation character in text mode -- just in case the text-mode and math-mode punctuation characters aren't the same -- and (c) allows whitespace (but not a line break) between the closing $$ character pair and the punctuation character.

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{luacode}
\begin{luacode}
function switch_punctuation ( s )
return ( s:gsub ( "%$%$%s-([%.%,])" , "\\,\\mbox{%1}$$" ) )
end
\end{luacode}
\AtBeginDocument{\directlua{luatexbase.add_to_callback(
"process_input_buffer", switch_punctuation , "switchpunctuation" )}}
\begin{document}
We have $$1+1=2$$, so $$1+1\neq 3$$ .
\end{document}
\[and\]. – Ulrike Fischer Mar 21 '20 at 10:52$$; and yes, the punctuation goes inside. – egreg Mar 21 '20 at 10:53$$? And why the punctuation goes inside, it's not a math,but a regular text , that I want (for example if I change my fonts)... @egreg @Ulrike Fischer – Thomas Mar 21 '20 at 10:55\[ … \]preferable to$$?. As for the punctuation, it needs to go inside, because there is no “look ahead” for it. You can use\text{,}, but this would mean you're using incompatible text and math fonts. – egreg Mar 21 '20 at 10:59\text{,}and zoomed in a million fold...no difference." E.g., did you use the default text and math fonts? – Mico Mar 22 '20 at 09:43