Two former Polish Cabinet ministers under investigation for corruption committed suicide today, authorities said, and Poland's government television said the suicides appeared to be connected to the probes of their activities.

The official Polish news agency PAP, in separate announcements a few hours apart, said Jerzy Olszewski, former foreign trade minister, and Edward Barszcz, former minister of construction, had committed suicide, but it gave no details about where or when the deaths took place.

There was no immediate indication whether the alleged suicides would affect the investigation of 280 senior Polish although officials said that two former prime ministers were questioned today by a commission looking into the charges.

Meanwhile, the Polish government indicated for the first time that there has been hostility directed by Poles against Soviet soldiers stationed in Poland, a development that could have serious repercussions in the sensitive relations between the two countries.

While giving no details of the incidents, PAP said there had been "scattered instances of misbehavior and even insults" against Soviet troops and that "the Cabinet states that these are inadmissible events." Polish television and PAP initially said the Soviet soldiers had been the object of "isolated assaults" but later corrected this to "insults" with no explanation.

About 40,000 Soviet troops are permanently stationed in Poland under a 1957 agreement, most of them at barracks in the Western town of Legnica.

Apart from occasional maneuvers with the Polish Army, the Soviet soldiers have maintained a low profile during the past year of turmoil.

Activists of the independent labor union organization Solidarity, however, have complained of alleged misbehavior by Soviet soldiers and of the Soviets buying out scarce food.

Such complaints have caused much embarrassment for the Polish authorities who now appear to be seeking to make amends to Moscow. The government statement described the attacks as "harmful to Polish interests."

"Soviet soldiers staying in our country fulfill a difficult and responsible service," it said. "Attempts to disturb this peaceful atmosphere, and the stirring up of anti-Soviet sentiments, contradict the spirit and the letter of allied relations."

The two men who reportedly committed suicide are among 280 former senior officials, including former premier Piotr Jaroszewicz and party leader Edward Gierek, who are being investigated on charges of corruption or abuse of office. Most are turned out of office during the political upheaval that accompanied the past year of labor unrest.

Both Olszewski and Barszcz had been stripped of their Communist Party membership following allegations that they used their official positions for private gain.

Jaroszewicz, who had served as premier for 10 years, and his successor, Edward Babiuch, who also has been replaced, both appeared before a Communist Party investigating commission today. Both admitted mistakes in the area of economic and political decision-making during their terms in office, officials reported.

As minister for foreign trade for five years, Olszewski had borne apart of the blame for the accumulation of the country's huge hard-currency debt now estimated at $27 million. Much of the debt went to buy foreign licenses under terms that later proved highly unfavorable to Poland.

Olsewski, 60, was implicated in a corruption scandal involving a foreign trade enterprise called Minex, whose director is now serving a lengthy prison sentence. The scandal originally blew up before last summer's wave of strikes -- Olszewski was relieved of his post in January 1980 -- but was only fully investigated late last year.

Barszcz, 57, is alleged to have been connected with the illegal building of luxurious villas for high political officials. A former mayor of the southern city of Krakow, he served as building minister from January to November 1980, when he, too, was dismissed.

Meanwhile, it appeared as though a compromise could be emerging over the issue of political prisoners, one of the major sources of dispute between the communist authorities and the Solidarity labor federation. Five imprisoned members of the rightist organization Confederation for an Independent Poland are to be visited by a team of doctors to determine whether they should be released from preventive detention on the grounds of ill health.

In addition, the Council of State, Poland's collective presidency, is to examine an appeal for clemency for two more rightists convicted of a bomb attack on a public building. No one was injured in the attack and Solidarity has included the two men on its list of political prisoners on the ground that their 25-year sentence was too severe.