I definitely had this before, but never sat down to ask "why" until now.

Basically, sometimes I encounter a "difficult" task, something that makes me use my brain I just stop doing it .
Like there's a problem, instead of trying to find a solution or steps, I just panic, not always an actual full-blown panic but just "zone out", brain fog, a sudden exhaustion like I could just pass out right there, and any further attempts someone makes to explain the issue, I'm just not having any of it , I don't want to hear what they have to say, and what they say I just can't "register", it's almost gibberish.

For example I was trying to learn to code years ago , I thought I had the idea, I typed in the lines of code then it didn't work even after several different attempts ,and that moment I just gave up, just like that . 
I zoned out, any attempts I made to read or re-read were absolutely useless, I tried so hard to read but, I could not understand anything .

Just a short while ago, I was watching a video on how to do digital shading and about halfway through this happened : I could not understand what was going on anymore, I could not piece together any information, I got extremely tired and this time I even got some slight shortness of breath and gastric reflux . 
I went to the comments and I could barely understand what the comments said either, the words the instructor spoke , the comments, made absolutely no sense, it all sounded and looked like absolute gibberish, my mind could not piece together what was going on .

I'd really like some opinions or advice on why this happens, I can't just hide from "difficult" tasks forever .