The subjunctive is a “mood” it demonstrates possibility and is used in certain grammatical structures. There is no pattern to these - you just have to learn them!
The most common are: purpose clause (following “ut” - so that); result clause (following a “flag word” and “ut” e.g. “tantus...ut” - so great that); indirect question (following a question word e.g. “quis” - the question is reported speech and the answer is doubtful).