Hello Fybf, about your question of these two sentences:
Las chicas a las que invito a almorzar viven cerca de la universidad.
Las chicas que invito a almorzar viven cerca de la universidad
The main difference is in the verb "invitar" rather than in other parts of these two sentences because it's not the same "invito" and "invitó". The word "invito" is an action that occurs at the present but "invitó" means an action occurs in the past. In both cases, the two sentences are correct. But you need to be aware where stress syllable is because the meaning could be different. That's why these two sentences sound a little difficult for understanding.
Let's see the two others sentences:
La chica, a la que quiero mucho, me regaló un libro.
La chica que quiero mucho me regaló un libro.
In this case, the commas make it sounds the sentence more formal in the first case rather than in the second one. Both mean the same but use a different register. One could sound politer and the another informal.
For all the sentences the word "que" works as a conjunction in the sentence. And "a la" refers to a feminine noun in this case "chica". In this case, when you use "a la que" is more specific and formal than only "que".