In order to know when we should use the subjunctive, we have to look at the context and the words that come with the verb. We use the subjunctive when there's uncertainty or doubt, when talking about a wish, hope, and about possibilities.Quiero que vengas a mi fiesta = I want you to come to my party ("quiero" expresses a wish/desire)No creo que apruebe el examen = I don't think I will pass the exam ("no creo" expresses doubt)Es posible que gane el concurso = it's possible that he will win the competition ("es posible" indicates possibility with uncertainty)Ojalá pudiera volver al pasado = I wish I could go back in time (the word "ojalá" is key in the use of the subjunctive, as it expresses a desire that you wish could be fulfilled but which you have no certainty about)
As with all verbs in Spanish, there's a different conjugation for each tense in the Subjunctive, but once you learn that and are able to identify in which situations the attitude of the speaker is in "subjunctive mode" it will be a lo easier to use it right