The subjunctive is associated with doubt so whenever an element of doubt is implied by the statement you are trying to compose eg I do not think/no pienso que triggers the subjunctive because you are doubting that something is the case. Other phrases like dudo que (I doubt that) and es posible que (it is possible that) also trigger subjunctive because they contain an element of doubt. This is the main factor that triggers subjunctive but there are others such as emotional reactions (me gusta que...) and futurity (vague time expressions eg cuando) which I can explain if you would like.