The [Fourth] Gospel is formally anonymous, which means that its author's name does not appear in the text of the work itself. This does not mean, however, that the text is intentionally anonymous, shielding its author's identity from the readers. From its beginning the Gospel speaks in a first person manner identical to other ancient books that were also formally anonymous but not intentionally anonymous (e.g. Lucian's Life of Demonax). For this reason, then, the Gospel was not intended to be formally anonymous, which almost certainly explains the title added to the Gospel sometime after its completion. Quite simply, book "publishing" in the ancient world was entirely different from today. Authors commonly spoke in the first person in a formally anonymous document because their works would have been circulated in the fist instance among friends or acquaintances of the author, who would know the author personally from the oral context in which the work was first read. Knowledge of authorship would would be passed on when copies were made for other (less familiar) readers, and the name would be noted with a brief title on the outside of the scroll or on a label affixed to the scroll.
No other title was ever used for any of the Gospels in known literature, a remarkable fact which demands that the titles be viewed as early or even original…To suggest a name other than "John" is to disregard the author-designating title affixed to the Gospel from its earliest stage of origin.
There are several kinds of ancient literary forms which have appendices as a normative feature. This was especially common in legal documents, for which "to label this…an 'appendix' or a 'supplement' is consequently misleading; it was not a merely postscript, dispensable as such, but rather the crucial means by which the business at hand was made legally binding upon its principals." Chapter 21 bears many resemblances to such legal documents, especially 21:24, which assumed the disposition of eyewitness testimony. This makes the subscription a requirement for the witness to be official, certifying the veracity of the report.
The Beloved Disciple declares himself to be an eyewitness of the things written in this book and therefore to be personally connected to the people and events themselves [21:24]. Although the character called the "Beloved Disciple" did not explicitly appear until chapter 13, he was almost certainly implicitly (i.e., anonymously) present in 1:40 with Andrew, Peter's brother, as one of the two first disciples of Jesus [cf. 146-47]. The placement of the Beloved Disciple as a witness at both the very beginning and the very end of the Gospel creates a technical literary device common in the ancient world called the inclusio of eyewitness testimony. This technique not only makes clear that this disciple fulfilled the requirements of apostolic testimony ("from the beginning you have been with me" [15:27]), but it also serves to solidify the witness as participating in the reliable practices of historiography. Edward Klink, John (Zondervan, 2016), 42-43; 892; 919.
Incidentally, the commentator's distinction between formal and intentional anonymity reminds me of the Inklings. Members of that literary circle (e.g. Tolkien, Lewis, Williams) shared drafts of their literary products with each other. These circulated anonymously, yet the identity of the authors was known to the recipients.