I will continue to celebrate Stan Lee's legacy in comic books (and more) with this series, The Life and Times of Stan Lee.
Generally speaking, the two most notable ways to write a comic book are the "Full Script Method" and the "Marvel Method."
In the full script method, a writer will write out a comic book script somewhat similar to a film screenplay, describing each panel for the artist to then draw. Some writers, like Alan Moore, get extremely detailed in what they want to have drawn on each panel. Here is a Moore script page from The Killing Joke, which he did with artist Brian Bolland...
The writer would then add dialogue to the finished pages (sometimes the writer would have already noted the dialogue that they are thinking of for the panels, but not always).
Then there is the Marvel Method, which involves the writer either delivering a general plot for the comic book issue to the artist, the writer and artist collaborating on a general plot for the issue or the artist coming up with the plot by themselves. These general plots can be all over the place in detail. They could consist of a written plot synopsis or it could be delivered verbally. The artist would then layout the pages for the story based on the plot and then the writer would add dialogue to the finished pages.
As you can easily see, the artist is obviously doing a whole lot more of the aspects of the comic that people traditionally associate with the "writing" of a comic book in the Marvel Method. They are the ones who figure out how to lay out a given plot as they draw the comic book. They might know that the issue involves Spider-Man fighting against Doctor Octopus over a weapon that Doctor Octopus stole from the Army, but the artist has to figure out how to go about having that theft and fight actually occur.
Here's the thing, though, that method was literally how Jack Kirby had been doing comic books since the 1940s! For years, Jack Kirby and Joe Simon worked together in a comic book partnership, where they would put out a series of comic books together. First they worked at Timely Comics and when Martin Goodman reneged on royalty payments that he promised them over their hit comic book creation, Captain America, they moved to National Comics (now DC Comics) where they were some of the first comic book creators popular enough that they actually had their names put on to the covers of the books to promote the fact that the comic in question was a Simon and Kirby comic book.
After World War II, the pair continued to work together for other comic book companies. They were essentially a modern day packaging studio. A comic book company could have their entire comic book line put out by Simon and Kirby and they knew they were in good hands. The two produced so many comic books that they tended to have a bit of an assembly line approach. Since Kirby could draw so much faster than Simon, the approach tended to be that Kirby would plot out his comic books (and sometimes help Simon plot out his comics) and then Kirby would draw his issues, with Simon later scripting Kirby's books and inking Kirby's books (Simon might have also occasionally co-plotted with Kirby on Kirby's books).
When they added more artists, obviously other artists would also ink Kirby and Simon (who still drew his own comic books, as well, just not at the same pace as Kirby).