The basic idea is that (pre-crisis) there were an infinite number of parallel Earths, all existing in the same time and place, but in different dimensions.
Originally, the major characters each existed in their own separate universe. you’d never see Superman or Batman or the Flash dropping in on each other. In the early forties, National Comics (which later became DC) bought out several smaller companies. They decided to combine all of the characters they had that didn’t have their own book and make them a team, which became the Justice Society. It included the Flash, Hawkman, Wonder Woman, Green Lantern, and a bunch of lesser heroes, usually magicians and costumed heroes. Basically everyone but Batman and Superman. This time from the late 30’s to roughly 1950 is the golden age.
Superhero comics fell apart in the early fifties, and really only the big two (Batman and Superman) were still making money. In 1958, a new Flash was introduced (beginning the silver age). A few years later, he met up with the original Flash from the 40’s. To explain this, the writer decided there was a second earth (Earth 2), and it was on this Earth that the golden age heroes lived. DC proceeded to introduce new, updated versions of its more popular characters, Hawkman, Wonder Woman, Green Lantern, etc. These characters were united into a Justice Society like team called the Justice League. With the concept of a second Earth already established, it wasn’t long until someone decided to team the Earth 1 Justice League with the Earth 2 Justice Society. There was for years a yearly crossover teaming the Justice Society and Justice League, which you can read in the “Crisis on Multiple Earths” trade paperbacks.
This created some continuity problems at the time. Superman and Batman had an unbroken continuity from the golden age through the silver age, yet seemed to have separate Earth 2 and Earth 1 characters, and some other characters, most notably Hawkman, were too easily confused as the silver age variant wasn’t sufficiently different from the golden age original. DC wasn’t exactly overly continuity conscious at the time, so such matters were left to the writers of the individual books to handle as they pleased.
Over time, a few other parallel universes popped up. Earth 3 had no superheroes, only evil versions of the Justice League. Fawcett had been bought out, creating an Earth S (for Shazam), that contained the Shazam family and their attendant villains. There were rare crossovers, but these were kept more or less separate.
Problems with continuity became worse as the years went by. The Earth 1 heroes had a sliding past history–their origins and early history happening just over “10 years ago”, and progressing very slowly. This means that, for example, in 1970, Superman, then not quite 30, had been around since about 1960. Now, in 2004, Superman is a bit older, in perhaps his late 30’s, so he’s been around since the late 80’s or so. The origin years slide forward constantly for these heroes. This works fine for the Earth 1 heroes, but the Justice Society has to have been active in the 40’s; they’re tied to the events of World War 2.
As we entered the 80’s this would put the Earth 2 heroes into their 60’s, while the veterans on Earth one stayed roughly 30. Real time aging on Earth 2 and comic time aging on Earth 1 created some discontinuity issues, which along with the proliferation of new parallel earths created by the purchase of other companies’ characters, writers overusing the concept, and confusion over the continuity of characters such as Superman, Batman, and Hawkman, created the need to clean things up. In addition, the bigwigs decided that it would be helpful to bring certain characters all into the main universe to make stories with them more accessible, the Shazam characters in particular, along with some heroes from Chalton that had been bought earlier.
This prompted the Crisis on Infinite Earths. The idea was to compress everyone into one universe, and take the opportuinity to restart some characters. Exactly how this was to be done, nobody could agree on, even after it was done.
Superman got a new origin. A miniseries explained his new background, after which he started about 5 years into his career. He was depowered, and all of the other Kryptonians were sent packing. Wonder Woman was sent back in time to before she existed, and she was started again from scratch. Flash was killed, and Kid Flash (who had been inactive due to a disease that killed him when he used his powers) had his powers restored, but in a much lesser form than the former Flash.
So just with those three, we have three different approaches: Start from scratch (Wonder Woman), reset the origin, but restart stories a few years in (Superman), and restart with a new character (Flash).
Because of this, and other problems, continuity was just as screwed up afterwards as it was before. They’ve tried to fix it a few times since, and many of the changes made are slowly being undone. Superman is being joined by other Kryptonians, Flash has light speed again, parallel universes have been reintroduced, and most of the characters have been seen in Elseworlds stories set in some of these parallel universes.
If you want multiple universes, Marvel’s gone the opposite direction. They regularly introduce new universes whenever it fits their needs. They had a regular series called What If, in which an interdimensional being called the Watcher would look at other universes and tell stories about how things would have turned out if certain events had gone differently, say if Uncle Ben hadn’t been killed. The conceit was that these weren’t “imaginary stories” like DC told, these actually happened, just in a parallel universe. The results were almost always disastrous for the characters.
In the late 80’s or early 90’s, one of the superteams, Excaliber, got lost and went dimension hopping through alternate realities. This was played mostly for laughs.
In 1996, they decided to restart many of their characters. They sent all of their characters other than the X-Men (and related) and Spider-Man into a new universe where they got new, modern origins, and clean slate to restart (this was called Heroes Reborn). It was so bad an idea, and handled so badly, that they abandoned it in a year, and brought everybody back (Heroes Return). It was very reminiscent of the Coke/New Coke/Coke Classic debacle in the 80’s.
All of the core books got a 2099 book which was a shared possible future. This fared no better than the Heroes reborn books and is thankfully no longer with us.
A few years later, they tried again, this time restarting just one character, Spider-Man, in a new universe of his own–Ultimate–while keeping the original in the core Marvel universe. Because they didn’t mess with the already existing Spider-Man, and because the relaunch was done much better, it worked better than they had hoped. Soon, they had X-Men and an amped-up version of the Avengers, and recently, the Fantastic Four.
Chris Claremont was given free reign a few years ago to take characters he’d created, and tell new stories with them, which essentially created a new universe just for that book (Extreme X-Men).
At about the same time, a new X-Team consisting of fringe characters, and characters from possible alternate futures was created and sent parallel world hopping much like in Excaliber, but this time played seriously (Exiles).
One issue of What If toyed with the idea of Spider-Man having a daughter, and the idea was so popular that they created a new series based on the idea, essentially another universe created to fit the one book.
Most recently, they’ve restarted several of their core characters under the label Marvel Age, which is retelling the early stories of the original characters. As they are reset in a modern time, I don’t know quite whether these are intended to be a separate universe or just a way to get new readers caught up on the ancient history of the characters. It doesn’t really work for the second purpose, and Spider-Man’s early stories have already been retold in a more modern setting once (In Spider-Man: Chapter One), so I’m treating this as a new universe of it’s own.
So counting all those, Marvel has about 819 different universes.