The subjunctive in Italian is very difficult to use and many native speakers still have problems when constructive sentences. Usually it is used for subordinate clauses after verbs such as pensare (to think) or credere (to believe) and his tense depends on the tense of the preceding verb and the timing of the actions. For simplicity, we use the verb credere.
If credere is at present indicative, I use a present subjunctive if the action in the subordinate is contemporaneous to the main clause one: ex. Credo che la festa stia andando bene = I believe that the party is going well
If credere is at present indicative, I use an imperfect subjunctive if the action in the subordinate is preceding the main clause one ex. Credo che la festa sia andata bene = I believe that the party was good
If credere is at past indicative (whichever past tense), I use an past subjunctive if the action in the subordinate is contemporaneous to the main clause one ex. Credevo che Marco fosse libero = I believed that Marco was free
If credere is at past indicative (whichever past tense), I use an “trapassato” subjunctive if the action in the subordinate is preceding the main clause one ex. Credevo che Marco fosse andato a scuola due giorni fa = I believed that Marco went to school two days ago