Surely you have apps (extensions) installed on your phone, potentially they could be phoning home and pulling down ads. Why this would only occur when you charge your phone is a mystery and not one I have had, so I have no personal experience of this.
There were lots of hist on a google search for - When I charge my Galaxy S25 random advertising web pages open up - I don’t know what you have tried.