The earliest texts of William Shakespeare's works were published during the 16th and 17th centuries in quarto or folio format. Folios are large, tall volumes; quartos are smaller, roughly half the size. The publications of the latter are usually abbreviated to Q1, Q2, etc., where the letter stands for "quarto" and the number for the first, second, or third edition published.
Eighteen of the 36 plays in the First Folio were printed in separate and individual editions prior to 1623. Pericles (1609) and The Two Noble Kinsmen (1634) also appeared separately before their inclusions in folio collections (the Shakespeare Third Folio and the second Beaumont and Fletcher folio, respectively). All of these were quarto editions, with two exceptions: The True Tragedy of Richard Duke of York, the first edition of Henry VI, Part 3, was printed in octavo form in 1595, as was the 1611 edition of The most lamentable tragedy of Titus Andronicus. In chronological order, these publications were:
Six of the preceding were classified as "bad quartos" by Alfred W. Pollard and other scholars associated with the New Bibliography. Popular plays like 1 Henry IV and Pericles were reprinted in their quarto editions even after the First Folio appeared, sometimes more than once.
Shakespeare's poems were also printed in quarto or octavo form:
Differing from the quartos of the plays, the first editions of Shakespeare's narrative poems are extremely well printed. "Richard Field, Shakespeare's first publisher and printer, was a Stratford man, probably a friend of Shakespeare, and the two produced an excellent text." Shakespeare may have had direct involvement in the publication of the two poems, as Ben Jonson exercised in reference to the publication of his works, but as Shakespeare clearly did not do in connection with his plays.
John Benson published a collected edition of Shakespeare's Poems in 1640; the poems were not added to collections of the plays until the 18th century. (The disputed miscellany The Passionate Pilgrim was only printed in octavo: twice in 1599, with another in 1612, all by William Jaggard.)
The folio format was reserved for expensive, prestigious volumes. During Shakespeare's lifetime, stage plays were not generally taken seriously as literature and not considered worthy of being collected into folios, so the plays printed while he was alive were printed as quartos. His poems were never included in his collected works until the eighteenth century.
It was not until 1616, the year of Shakespeare's death, that Ben Jonson defied convention by issuing a folio collection of his own plays and poems. Seven years later the folio volume Mr. William Shakespeare's Comedies, Histories & Tragedies appeared; this edition is now called the First Folio. It contains 36 plays, 18 of which were printed for the first time. Because Shakespeare was dead, the folio was compiled by John Heminges and Henry Condell (fellow actors in Shakespeare's company), and arranged into comedies, histories and tragedies. The First Folio is generally looked to by actors and directors as the purest form of Shakespeare's text. While punctuation and grammar aren't always accurate by today's rules, these things served as direction to the actors on how to say the lines.
The First Folio was compiled by Heminges and Condell -- but it was published by a trio of stationers (booksellers and publishers): William Jaggard, his son Isaac Jaggard, and Edward Blount. (William Aspley and John Smethwick participated in the endeavor as subsidiary partners.) It contained, in addition to blandishments provided by various admirers of Shakespeare, such as the dedication signed by "John Heminge and Henry Condell", 36 plays (including Troilus and Cressida, which was not, however, listed in the table of contents, but omitting Pericles and The Two Noble Kinsmen, which are now usually considered canonical). The Jaggards were printers, and did the actual printing of the book. The elder Jaggard has seemed an odd choice to many commentators, given his problematical relationship with the Shakespeare canon: Jaggard issued the suspect collection The Passionate Pilgrim in 1599 and 1612, and in 1619 printed the so-called False Folio, ten pirated or spurious Shakespearean plays, some with false dates and title pages. It is thought that the printing of the First Folio was such an enormous task that the Jaggards' shop was simply needed to get the job done. (William Jaggard was old, infirm, and blind by 1623, and in fact died a month before the First Folio was complete.)
The First Folio was reprinted three times in the 17th century:
The Second Folio appeared in 1632. Isaac Jaggard had died in 1627, and Edward Blount had transferred his rights to stationer Robert Allot in 1630. The Second Folio was published by Allot, William Aspley, Richard Hawkins, Richard Meighen, and John Smethwick, and printed by Thomas Cotes. It contained the same plays as the First Folio and much of the same additional material, with the addition of an unsigned poem by John Milton.
The Third Folio was issued in 1663, published by Philip Chetwinde; Chetwinde had married Robert Allot's widow and so obtained the rights to the book. To the second impression of the Third Folio (1664) he added seven plays, namely Pericles, Prince of Tyre; Locrine; The London Prodigal; The Puritan; Sir John Oldcastle; Thomas Lord Cromwell; and A Yorkshire Tragedy. (See: Shakespeare Apocrypha.) All seven of these additional plays had been published as quartos while Shakespeare was alive, but only Pericles was eventually widely accepted into the Shakespearean canon.
The quartos of Pericles (1609 and 1611), The London Prodigal (1605) and A Yorkshire Tragedy (1608) were all attributed to William Shakespeare on their front pages. The quartos of Locrine (1595), The Puritan (1607) and Thomas Lord Cromwell (1602 and 1613) were attributed to W. S. on their title pages, but Shakespeare was not the only playwright with those initials; Wentworth Smith has been put forward as another possible author of these works. Sir John Oldcastle was printed in 1619, three years after Shakespeare's death, as part of the False Folio. It was attributed to Shakespeare on its title page which also bore a false date of 1600.
The Third Folio is relatively rare, compared to the Second and Fourth, probably because unsold copies were destroyed in the Great Fire of London in 1666. One surviving copy was purchased by the Irish High Court judge and antiquarian William O'Brien in the 1880s. It was put up for auction by Sothebys in 2017.
The Fourth Folio appeared in 1685, published by R. Bentley, E. Brewster, R. Chiswell, and H. Herringman. It contains the same 43 plays as the Third Folio. (Brewster, Chiswell, and Herringman were members of the six-man syndicate that published the third Ben Jonson folio in 1692; Herringman was one of three stationers who issued the second Beaumont and Fletcher folio in 1679.)
The Fourth Folio in turn served as the base for the series of eighteenth-century editions of Shakespeare's plays. Nicholas Rowe used the Fourth Folio text as the foundation of his 1709 edition, and subsequent editors -- Pope, Theobald, etc. -- both adapted and reacted to Rowe's text in their own editions. (See: Shakespeare's Editors.)
The Two Noble Kinsmen did not appear in any Folio edition, was not printed until 1634, although there is evidence of its being performed much earlier. The title page said "written by the memorable worthies of their time: Mr. John Fletcher and Mr. William Shakspeare [sic], Gent."  It was not included in most editions of Shakespeare (e.g., the Cambridge/Globe editions of Wright and Clark, ca. 1863) until the latter half of the 19th century (it appears, e.g., in Dyce's collected Works of Shakespeare in 1876) but it was not generally accepted into the Shakespeare canon until well into the 20th century, when, for example, it was included in the Riverside edition of 1974.