Consider the following bar magnet, with the unphysical field lines drawn around it. The real magnetic vector field is tangent to these lines and is represented by black triangles (a magnetic vector field always emanates from the north pole to end up at the south pole, though it continues inside the magnet):
Now consider the following picture of two of equivalent magnetic bars and the associated field lines (in which for every field line only one direction of the magnetic vector field vector is shown by a very small triangle):
Field lines are always closed lines. This is easy to see in the single magnet (the lines continue inside the magnet). All field lines between the two magnets are connected (via the lines inside the magnets) with the lines on the far- left and far-right directed away from the magnets (which makes them closed, though that's hard to visualize).
Now when we pull the magnets away from each other (to form two separate bar magnets), the field lines between the magnets (which are actually not separate, but you can't draw an infinity of field lines) move away from each other too, like the lines on the left and right of the double bar magnet arrangement. The field lines on the far left bend up (forming closed lines with the right ones bending up, which makes their closed Nature visible, like the single lines already bending inward are closed) to connect with the field lines on the left of the field lines in the middle (wrt to a vertical line in the middle of the two magnets). So these lines in the middle seem to "snap", just as the closed lines emerging from the left and entering on the right after which they reconnect to form two closed loops in each magnet. The reversed process, i.e. two closed lines forming one closed line (which is also a form of snapping), occurs, as you might have guessed when bringing two bar magnets together, in the same arrangement as depicted, to form one bar magnet.
Because we pull the magnets apart the potential energy contained in the magnetic fields of two bar magnets is bigger than in a single one (if the two bar magnets were made from a single one by cutting it in two). You can imagine pulling them away from each other, and "snap!", two magnets with higher energy will emerge (actually the energy increases by infinite snaps in a continuous way, but separating them very fast will feel like a single snap).
The magnetic fields around the bar magnets are produced by the spins of unpaired electrons in the outer shell of the atoms. Each spin produces a tiny magnetic field and in ferromagnets (which are the ones we consider here), if the temperature is not too high, all these tiny fields are permanently aligned, which minimizes the internal energy of the ferromagnet.
Now, these kinds of processes (in very distorted ways and on much bigger scales) also take place on the surface of the Sun, but the (closed) magnetic vector fields are produced by huge plasma currents and the magnetic field lines are closed lines around these plasma currents. These plasma currents constantly change and thus the magnetic field lines. This induces electric fields, which accelerate charged particles, mainly protons, electrons, and a relatively small fraction helium nuclei (solar cosmic rays). When two or more closed field lines emerge from one closed field line (for example when one plasma current splits in two or more), the induced electric field becomes suddenly higher and this sudden increase of the induced electric field gives a burst of high energy protons, electrons, and helium (alpha particle).
So just as in the case of two magnets that are separated very fast, thereby increasing the magnetic field energy in a snap, the sudden increase in the magnetic field's energy is converted into a burst of cosmic radiation, which reduces the energy contained in the magnetic fields around the two (or more) emerging plasma currents (because of which the plasma currents are reduced in strength as a reaction). The difference with the case of the two magnets is that the increased energy in the magnetic field of the two magnets stays (approximately) the same, without imparting the increased energy to other stuff.
You can compare it with the lines of equal pressure in the weather developing. These lines are always closed too and they can merge or split to form new closed lines of equal pressure. The associated energies are contained in the winds. When one closed low-pressure line "snaps" into two closed lines, more wind energy will be released than in the case of the one closed low-pressure line.