I’ve always had a hard time wrapping my head around the idea that the universe could be both finite and infinite at the same time (or something like that *takes bong rip*), but this passage from Coming of Age in the Milky Way by Timothy Ferris succinctly explains what’s going on:

General relativity resolved the matter by establishing that the universe could be both finite — i.e., could contain a finite number of stars in a finite volume of space — and unbounded. The key to this realization lay in Einstein’s demonstration that, since matter warps space, the sum total of the mass in all the galaxies might be sufficient to wrap space around themselves. The result would be a closed, four-dimensionally spherical cosmos, in which any observer, anywhere in the universe, would see galaxies stretching deep into space in every direction, and would conclude, correctly, that there is no end to space. Yet the amount of space in a closed universe would nonetheless be finite: An adventurer with time to spare could eventually visit every galaxy, yet would never reach an edge of space. Just as the surface of the earth is finite but unbounded in two dimensions (we can wander wherever we like, and will not fall off the edge of the earth) so a closed four-dimensional universe is finite but unbounded to us who observe it in three dimensions.

In the terms of Edwin Abbott Abbott’s Flatland: A Romance of Many Dimensions, we are Flatlanders living in a Lineland world who, with the aid of mathematics, have been able to peer into Spaceland.