Due to sun’s differential rotation, the magnetic field of the sun gets dragged and stretched and it breaks
After breaking, it reconnects in complicated ways
Sometimes they anchor on two places on the sun and sometimes only one and when anchored, the magnetic field is very high so for balance, the thermal pressure decreases so these spots are cooler than the rest and appear black