A nucleus of an atom can be compared to the sun of a solar system because the nucleus, like the sun, is the largest part of an atom and its electrons orbit around it, much like planets in a solar system. Atoms can also gain or lose electrons similarly to how stars can gain or lose planets.
However, it is important to note a few areas where atoms and solar systems differ. Stars keep planets in orbit through gravity, while nuclei hold electrons through nuclear forces. In addition, experts often emphasize that electrons are not in orbit in the same way that planets are. The location of an electron is probabilistic, so it is not possible to know exactly where it is located at any particular time. In some ways, electrons are in multiple locations at once and they only exist at a specific point if they are observed or otherwise forced to "choose" a position.
However, experts still generally use the solar system model as a means of making the concepts understandable. Since atoms typically operate differently than objects people encounter on a daily basis, analogies make them understandable, and the orbit analogy has proven popular throughout the years.