Polish Communist Party leader Stanislaw Kania flew to Prague today and held a surprise meeting with Gustav Husak, Czechoslovakia's president and longtime party leader.

No reason was given for the previously unannounced visit, but foreign observers here interpreted it as part of the preparation for next week's Soviet Communist Party congress in Moscow, which will be attended by all Eastern European leaders. The Czechoslovak and East German media have taken a lead in denouncing what they described as the activities of "counterrevolutionary forces" in Poland.

According to an official communique issued after Kania's meeting with Husak today, the two leaders briefed each other on events in their countries and reached "an identity of views" on all subjects discussed. It was assumed that Kania, who returned to Warsaw this evening, explained the background to the appointment last week of Gen. Wojciech Jaruzelski as a premier.

By paying a brief visit to Czechoslovakia before the Moscow congress, Kania may be hoping to defuse some of the hard-line criticism that will undoubtedly be leveled at the Polish party in Moscow. Although not formally on the agenda, the Polish crisis is likely to be a major topic in backstage talks at the congress.

Husak spelled out his views on Poland yesterday at a meeting of party activists at which he said Czechoslovakia could not remain indifferent to its northern neighbor's destiny. He accused counterrevolutionary forces of attempting to destabilize Poland and drew a parallel with the Czechoslovak experience in 1968 and 1969, when a reform movement was reversed by a Soviet Bloc invasion.

"Czechoslovak Communists remember only too well what confusion, chaos and demagoguery they had to fight against [during those years] and how they put a stop to it," he said.

Husak, who presided over the "normalization process" in Czechoslovakia after the invasion when tens of thousands of people identified with the reforms lost their jobs, said the Polish keep Poland socialist. But he also praised Polish leader for taking a positive stand against "economic chaos" at last week's Central Committee meeting.

Polish television today carried pictures of Husak and Kania looking relaxed and cheerful during their meeting at Prague Castle. Kania's flying visit to Prague illustrates a recurring dilemma faced by the Polish leadership: whether to pay greater attention to the concerns of the Soviet Bloc allies or to those of disaffected Solidarity members within Poland itself.

The recent past has shown that it is usually not possible to satisfy both conflicting pressure groups at once. At time when the Polish leadership has taken a tougher line toward Solidarity, thus pleasing Prague and Moscow, strikes and other forms of social unrest have mounted.

When the Polish authorities have bought industrial peace by making concessions to the unions, however, the Soviet Bloc has shown its dissatisfaction by stepping up media criticism against Solidarity and by other forms of pressure.

Each side clearly has different expectations from Jaruzelski's appointment.

The Kremlin and its allies expect the new soldier-premier to take a firmer stand against what they see as the threat of anarchy and chaos. Solidarity, on the other hand, expects a policy of dialogue and conciliation.

It is still impossible to predict whether the reinforced Polish leadership will be able to resolve this dilemma. But an important element in the balancing act is to try to persuade other communist parties, including the Czechoslovak, that it is in their interests to accept social change in Poland.

Industrial unrest in Poland has subsided almost entirely since Jaruzelski's appointment as the independent union federation Solidarity awaits the government's first moves.

The main immediate task facing the Polish authorities is to prevent the escalation of a 25-day-old stike in the central city of Lodz of students demanding an independent union organization.

This evening Education Minister Janusz Gorski, went on television to say an agreement was close, and he appealed to the Lodz students not to carry through their threat of convoking a nationwide sympathy strike. Medical students in Warsaw, who had been holding a sit-in in support of the Lodz student cause, announced almost immediately after Gorski's broadcast that they would end their action and called on other students across the country to follow their example to avoid jeopardizing a possible settlement in Lodz.

A draft agreement with the Lodz students, which will apply nationwide, provides for greater university autonomy, student representation on university boards and curriculum reforms.