Why do some papers have 10-20 co-authors? I am new to the field of academia, and when performing a literature review for really any topic, I am puzzled as to why some papers have so many co-authors.

Most papers have only about 1-5 authors which I can understand but I can't seem to understand how 10-20 people could all meaningfully contribute to a single paper. How possible is it that co-authorship is being gifted?

Are there any reasons why so many co-authors could be justified?

Update 11/11/19:
Some comments have suggested this question may be a duplicate. To clarify: I was not referring to large-scale taskforces that produce world-changing results such as the Higgs Boson project (What is the point of listing 1000 authors for a single scientific paper?). Those projects clearly play by different rules. I was meaning routine contributions to journals (such as a new formula or algorithm) where I struggle to understand how so many people could all meaningfully contribute to a small (albeit important) idea.
In my field, where author numbers between one and six are the norm, reasons for having more include the following:


The paper results from a large-scale collaboration between different groups that developed different parts of the overall work.
The paper is supposed to give a broad picture overview of something, like in the case of a survey paper or a research roadmap paper. The authors are experts for the different considered areas.
The paper results from a collaborative brainstorming effort. Such papers are sometimes written by the participants of a research meeting (like the famous Dagstuhl seminars), or a breakout group from such.
The paper results from a student project, and most of the co-authors are actually students.