How to deal with a mentor asking for sudden tasks Consider the following conversation:

Mentor: What is your progress?
Me: blah.... blah... blah...
Mentor: Okay.
Me: What about other tasks (if any)?
Mentor: Do not worry about them, I can handle, if any. You focus only on your own
research work
Me: okay.

After a week, while I am doing research work, the mentor comes to the lab suddenly, and then the conversation will be like

Mentor: There is a class today with the syllabus X for batch Z.
Me: Okay.
Mentor: Go and deal. It will be in an hour.
Me: I am aware of X, but don't know in detail.
Mentor: Not a big deal. Carry on with today's class.

This is a sample scenario. There will be many tasks like this with very shorter deadlines.
The only issue I face is maintaining a trade-off between personal accountability and stress. By behavior, I want to be more accountable for any task done by me. But due to the shortness of time, I sometimes experience so much stress (in order to maintain accountability).
How to deal with such mentors?
This answer depends on your relationship with your supervisor. If have an honest, open relationship, I would suggest communicating your feelings in a professional and constructive way. For example,

I appreciate you trusting me to take on additional Tasks 1, 2, and 3. However, I already have tasks A, B, and C which require a significant amount of my time. I am happy to do Tasks 1, 2, and 3, but I would benefit from additional notice (24/48/72) hours in order to carry out the task with a high quality. Does that sound agreeable to you?

If you do not want to do additional Tasks 1, 2, and 3 but feel pressured to do so, you always have other options:

Build evidence of your situation and eventually present it matter-of-factually to your supervisor. For example, 'You have requested me to do additional Tasks 1, 2, and 3 repeatedly, and my progress on research and other commitments are suffering. I cannot do these additional tasks any more.'
If 1 fails, build further evidence of your situation and present it to the graduate director.
If you have the willpower to do so, you might accept your fate and make lemonade out of lemons. For example, record each extra lecture you do to add to your teaching CV. Or, at the very least, start to prepare in advance for Tasks 1, 2, 3, ... n.

Sudden tasks are not fun and can indeed be a cause for significant personal stress. It sounds like these requests come during the workday, but otherwise I would suggest sticking to a strict work schedule with dedicated days of no work.