There’s a redaction here: My bad: If atoms are mostly made up of empty space, why do things feel solid?) Atoms can share electrons, or their electrons can move so that they behave like attracting magnets, and a whole mess of other things. For example, attractive van der Waal forces can show up when atoms are close, but not too close. Addressing the fact that matter is mostly empty space, if you really squeeze matter you’ll find that the electrical forces can no longer hold atoms apart. Once all the charges are out of the way the atoms (now balls of neutrons) are free to collapse together.