Hello Norli!
The Sun is an important part of the processes that cause the northern and southern lights. The Earth's magnetosphere and ionosphere are the other two things that a planet needs to have aurora. The aurora or northern and southern lights are produced by a complicated set of interactions between the solar wind and Earth's magnetic field. The solar wind flow is normally diverted around Earth's magnetosphere, but when the interplanetary magnetic field in the solar wind points in just the right direction, a process called magnetic reconnection can occur. Magnetic reconnection on the dayside can erode away at the magnetic flux on Earth's dayside and cause field lines to convect back to the Earth's nightside. These magnetic field lines become part of the long, stretched magnetotail that extends far beyond the Earth on the nightside. Eventually, the magnetotail becomes unstable, and reconnection will start on the nightside, and all of the energy deposited there will explode towards the Earth. This generates huge electrical currents that go all the way down to Earth's surface, and sends streams of electrons and protons down into Earth's ionosphere. These protons and electrons will excite nitrogen and oxygen in the ionosphere and cause them to emit the green and red light we see as the aurora. The aurora occur in a ring around the Earth's north and south magnetic poles because of the convection processes associated with the interaction between the solar wind and magnetosphere, and where what scientists call the "footpoints" of the reconnecting magnetic field lines map down into the ionosphere. This animation is a good illustration of how this process works.
https://www.youtube.com/watch?v=mgUZwoR0gcE NASA currently has a satellite mission called Magnetospheric Multiscale that has four spacecraft orbiting the Earth to help us understand magnetic reconnection and what makes the aurora.
If a planet has a magnetic field like Mercury, but no atmosphere, it will not have aurora. If a planet has an atmosphere, but not much of a magnetic field, solar wind ions can impact the atmosphere and produce photons, like on Mars, but it will not look like Earth's aurora. Jupiter and Saturn have atmospheres and strong magnetic fields. They have aurora that are like the ones we see on Earth in some ways, and different in other ways due to the structure of their magnetospheres.
Kris