"¡Ellos invitaron a todo el mundo!"
Translation:They invited everyone!
literally, it's "all the world" I think that should be accepted, my understanding is that saying "todo el mundo" is a hyperbolic way of saying "everyone" like here the person seems shocked at how many people were invited (hence the exclamation points) But I'm not a native speaker, so I could be wrong.
why is this 'everyone' but "toda la familia" means 'the whole family'? Why does this phrase not translate to 'the whole world'?
It does translate to "the whole world" too, but generally it's an idiom meaning "everybody".