Something is "injecting" adds into your web pages. If this happens only on Safari, most likely there is some Safari extension which does it.
Or some other malware. For example, did you install shareware apps or something from shareware sites? Those sites used to be useful years ago for finding hard-to-find shareware software, today they host "free" software crap, which is bundled with malware like coin-mining software and web add injectors. You install free software and get this ugly payload installed also. And then this happens... You will need to find it and remove it.
Check Safari extensions and disable/remove any you do not know and do not want. Or simply disable all and see, if this stops. Then enable one by one and identify which does it. With malware it is bit more complicated, run scan by malwarebytes, that should tell you what is happening.
Install software only from App store or directly from developer web site.