Their bodies were found just outside the wreckage of the building, and officials said they believed that both had been trying to flee when the explosions occurred. 2 Admitted to Hospital

A spokesman for Brookhaven Memorial Hospital in Patchogue, Kevin Miller, reported that 24 people, including several children and infants, had been treated for cuts, bruises, fractures and other minor injuries. All but two were released. One of them, Gertrude Barzilay, 56, of Bellport, was admitted to the intensive-care unit with chest pains; the other, George Perez, 24, also of Bellport, was admitted with respiratory problems.

At least four Grucci family members were treated. Felix Grucci Sr., the company's 78-year-old founder, and his wife, Concetta, 65, were treated for what was described as excessive stress. Their daughter, Donna Grucci Butler, 43, and a grandson, Vincent Grucci, 19, sustained minor injuries.

Some of the injured were Grucci employees working on fireworks for Christmas displays. Most, however, were people who lived near the plant, Mr. Miller said.

Edward Thompson, a Red Cross official at the scene, said that the explosions had left 50 homes within about a half mile of the factory ''uninhabitable'' and that ''another 50 have a lot of major problems.''

The police said the blast created an implosion, a suction effect that blew the windows of neighborhood buildings outward rather than inward. A blast that blew the windows inward might have caused many more injuries, they noted.

Dozens of Smaller Fires

As flames engulfed buildings on the site, witnesses said dozens of smaller fires were touched off by flaming debris that came down as far as eight miles away. As firemen fought the flames, the police set up roadblocks surrounding the area and allowed no one to enter, not even residents who had been away from their homes at the time of the blast. Police officials said they feared homes might otherwise be looted.