It began unremarkably enough with the sort of stuff that fills every campaign for political office -- a children's Halloween costume contest. On this occasion the event occurred in a Laurel shopping center and Gladys Spellman, then running an easy race for a fourth term in Congress, was putting in a late afternoon appearance, smiling, chatting, touching people.

Minutes later, when this uneventful incident turned tragic and the 62-year-old Democratic politician collapsed with heart failure and possibly permanent brain damage, the Prince George's County political world was thrown into turmoil and every congressional hopeful was confronted with the possibility of an open seat in Congress for the first time in seven years.

For months they surreptitiously jockeyed and hustled to get in position "just in case." But the scrabling only went public last month after the U.S. House of Representatives, in an unprecedented act, declared Spellman's seat vacant because of her continuing stroke-like illness. Shortly afterward, Gov. Harry Hughes called a special election.

And so it is that five months after Spellman collapsed and was rushed to a hospital, 32 men and women have become official candidates to finish out Spellman's term in the 5th district congressional seat. All but one, who is running as an official write-in candidate, will appear on the ballot in the special Republican and Democratic primaries Tuesday, April 7. The winner of each of those contests, along with the solitary write-in contestant, will then compete in an election May 19 that has already been called the first referendum on the Reagan administration.

The race is the most crowded congressional contest in Maryland history and one of the quickest (only three weeks between the filing deadline and the primary) and as a result, most of the candidates have been unable to get their names or positions known or raise much money. But at the same time, the large number of contestants, including several prominent elected officials, has made the race one of the country's most interesting - and unpredictable - in several years.

On the Republican side, the first intense primary battle in nearly a decade has developed. Although 12 candidates are on the official ballot, only Lawrence Hogan Jr. or Audrey Scott are given a serious chance of winning a primary in which 8,000 votes are expected to be cast. A third candidate, newcomer John Lilliard, has attracted some supporters, but has little chance of winning.

Hogan, the 24-year-old son and namesake of the powerful Prince George's county executive, has been campaigning, like most of the Republicans, in support of Reagan in all but a few areas. Hogan has been both helped and hurt by his famous father: he has had access to supporters and financial resources from his father's past political efforts but he has also been subject to charges that his father is attempting to establish a political machine.

Bowie Mayor Scott has encountered fundraising difficulties. She has stressed the experience she has gained as mayor of one of the largest cities in the state in dealing with constituents and public problems and has attacked Hogan as too young and inexperienced for the job.

On the Democratic side, any one of four candidates among the 19 on the ballot could win a plurality of the 20,000 votes expected in the Democratic primary. Two other Democratic primary. Two other Democratic candidates are considered only longshots but could affect the race's outcome.

Spellman's husband, Reuben, was intitially seen as the easy winner in the race because of a large sympathy vote. Spellman, who for years grumbled about politics and wanted his wife to quit it, has been telling voters that he will simply carry on her work. Like Hogan, Spellman's biggest asset is his well-recognized name. His greatest problem is a lack of experience and age - he is 71 and recently underwent open heart surgery.

Spellman's toughest opponent is Steny Hoyer, the former Prince George's senator who ran the county's powerful Democratic organization has crumbled in the last two years, many of its stalwarts are backing Hoyer. A liberal Democrat, Hoyer has avoided harsh attacks on Reagan, and has instead stressed "effectiveness" in Congress and his past track record as a state senator and president of the Maryland Senate.

Across the ideological spectrum is Democratic County Council Member Sue Mills, who rose to power on a conservative anti-busing stance in the early 1970s. Mills is considered a strong candidate because many voters remember her vocal opposition in 1973 to the federal court-ordered busing plan and have loyally supported her even since. Mills' greatest problem is that many liberal and moderate Democrats view Mills as a threat and may go to the polls specifically to vote against her.

Although he has only just begun or organize a campaign, Sen. Edward Conroy or Bowie is considered a major candidate for three reasons: he has name recognition from his unsuccessful U.S. Senate race last November; he is supported by the veterans and anti-abortion forces and he has a strong base in Bowie, which generally has a high voter turnout.

Finally, Montgomery County Del. Stewart Bainum, a liberal, and Prince George's Sen. Thomas O'Reilly, a conservative, are considered longshots in the Democratic primary. Bainum, a businessman from a wealthy family, has spent the most money so far. However, his Montgomery identification and his wealthy background may hurt him among Prince George's voters. O'Reilly has done little to get his campaign off the ground so far but like Conroy, he has many supporters among anti-abortion groups.