There could be many reasons for this. First, your performance may depend on the nature of the task and your approach to completing the task. Different tasks may require different approaches and you may find yourself more capable in certain areas than in others. For example, some students may feel confident writing essays, although perhaps not very confident responding to questions targeting unseen texts.
First, you should identify the errors that you made in the task that resulted in a lower mark. Teachers usually provide feedback that covers the positive and negative aspects of your response(s) and sometimes suggestions for improvement. If you have been offered such feedback, you should consider it and incorporate suggestions into your study strategy/approach to completing an assignment going forward. If you feel that the feedback you have received is not enough or not sufficiently clear, you should discuss your performance with your teacher, who can then provide more in-depth feedback and suggestions for improvement.
Second, you should regularly practice writing essays and responding to questions targeting unseen texts, while also revising your texts (including quotes and techniques), as this can help identify areas of improvement that you can gradually address. You should also request feedback from your teacher whenever you complete practice material to help you further.
I hope this helps!