It comes from the Spanish word "cafetería", which literally means "coffee shop" or "coffee house".
The word entered English in the early 20th century, as the concept of self-service restaurants, particularly in schools and workplaces, became popular.