Friends who eat McDonald's and KFC will often find that there will be a big table occupied by some students or a group of people, as if they were brainstorming at McDonald's or KFC. Compared with the library or office, studying together in the coffee shop will make the environment more relaxed, but it can also maintain a certain efficiency. And you can order food directly when you are hungry, and you won't interrupt your study because you want to eat.
There are also a group of people who go to coffee shops to study because they can't find a better library and study place at home or near home. Coffee shops are generally quiet, and drinking coffee can refresh you. Nowadays, the role of coffee shops is becoming more and more social, not only to meet people's demand for coffee. For example, if you want to meet a friend in your life, you may not go to a restaurant or a friend's house, but invite her to a coffee shop. I once heard an interview with a writer, not in his home, but in a coffee shop, because there will be a feeling of being too formal at home, and a coffee shop can provide a more formal but not rigid environment.
Personally, I prefer studying in a coffee shop to a coffee shop. In fact, the library is crowded and noisy. If you choose the right coffee shop, it may even be quieter than the library. And the learning environment in the coffee shop will definitely be more relaxed than that in the library.