Solar flares are caused by solar storms. This is caused by tangling, corssing, or reorganizing of magnetic field lines on the Sun. These cause charged gases to be ejected from the Sun. As more of these solar flares happen, they turn into solar storms and release a lot of energy into space!