The subjunctive tense can be some what confusing at first, in fact it's technically a "mood" rather than a tense. Other moods include the indicative and the imperative. Where the indicative mood is used to express facts or belief (e.g. Something happened today that made me really happy) the subjunctive is used to express desires, doubts, emotions, or things that are abstract or unknown (e.g. I doubt she went to the shops yesterday).
An easy way to start to recognise when to use this mood is to use the WEIRDO method:Wishes (and desires) - quisiera que...Expressing emotions - me alegro que...Impersonal expressions - es importante que...Recommendations or requests - recomiendo que...Doubt or denial - dudo que...¡Ojala! - ojala que...