Bar magnets are some of the simplest magnetic objects that are out there - with a positive end and a negative end, and a smooth connection of field lines connecting top to bottom, cylindrically encasing the whole magnet. If you’ve ever played with any of those “doodle a hairdo” games that are made of iron filings, you’ve seen the shape of the magnetic field lines.
The Earths’ magnetic field is pretty straightforward as magnetic fields on planets go - its magnetic field is fueled by the motion of our iron core. If you have a magnetic material moving (as our core is), you can produce a magnetic field pretty straightforwardly. Unlike a bar magnet, though, the magnetic north and south poles aren’t as fixed to a single position on the surface of the Earth. The bar magnet is a magnet because we’ve produced the metal to contain a specific property. But the Earth’s magnetic field is produced on the fly, and is influenced by the exact content of the metals flowing around in the core and mantle. If you’re near the poles, you can watch Magnetic North drift by a few degrees every year. Magnetic North is distinct from Geographic North. Geographic north is the physical point where no stars would rise or set, since you’re exactly at the top of the spinning Earth. Magnetic North is the top end of the magnetic field, and is often not at the same place.
The Sun is even more complex. It also forms its magnetic field on the fly, through internal motion, and creates a magnetic field that surrounds it, and at first, it looks like your standard bar magnet diagram again. But, unlike the Earth, the sun doesn’t rotate as a solid body. The equator of the sun rotates faster than the poles do, and it pulls the magnetic field along with it. Over time (and we’re talking years, here, not billions of years) the magnetic field of the sun gets increasingly tangled, which eventually causes the magnetic field to twist up on itself, forming sunspots. After 11 years, the Sun’s magnetic field resets entirely. But it resets by flipping over - the positive end of the magnet, had it been pointing up, is now pointing down. After another 11 years, it’ll reset again, and flip back up the way it had been previously. This 11 (or 22) year cycle has been a consistent feature of our Sun for as long as we’ve been observing it!
So, while the sun does have a magnetic field, with both a north and south pole like a bar magnet, it’s also very unlike a magnet and the Earth, because that magnetic field is complex, and changes dramatically over time.