The picture we often have of electrons as small objects circling a nucleus in well defined "orbits" is actually quite wrong. The positions of these electrons at any given time are not well-defined, but we CAN figure out the volume of space where we are likely to find a given electron if we do an experiment to look. For example, the electron in a hydrogen atom likes to occupy a spherical volume surrounding the proton. If you think of the proton as a grain of salt, then the electron is about equally likely to be found anywhere inside a ten foot radius sphere surrounding this grain, kind of like a cloud.
The weird thing about that cloud is that its spread in space is related to the spread of possible momenta (or velocities) of the electron. So here's the key point, which we won't pretend to explain here. The more squashed in the cloud gets, the more spread out the range of momenta has to get. That's called Heisenberg's uncertainty principle. Big momenta mean big kinetic energies. So the cloud can lower its potential energy by squishing in closer to the nucleus, but when it squishes in too far its kinetic energy goes up more than its potential energy goes down. So it settles at a happy medium, and that gives the cloud and thus the atom its size.
please like if you are satisfied