She said she pulled out because her mind isn’t right and she risks doing herself serious physical injury.
I completely understand that, I don’t think people realise how dangerous gymnastics is and the fine margins between perfection and disaster. You have to be fully committed to every single thing you do and do it with a clear focused mind. A yip in most other sports might result in a missed shot, in gymnastics it could result in you landing on your neck from 3m with serious momentum from whatever twist you just executed. I did gymnastics from the ages of 4-12 and got the yips on the vault. This was when it was a pommel horse, length ways with no handles rather than this new shape thing they use now. One time I got my run up wrong and hit the spring board too low and went chest first into the end of it. From then on I just couldn’t get my run up right and never hit the spring board with any confidence and my vaults were dangerous from then on because I was barely clearing the vault and could easily have smashed my back on exit. Obviously that’s just a child doing low level gymnastics but the stakes are increased magnitudes with the level of difficulty, speed and power they achieve.
I have a similar memory to yours, but trampolining. I was about 15 though and well aware that while I was good at lots of sports I was never going to be great at any. At any rate, I went to do 1 and 1/2 back somersault and a thought flashed into my mind - "miss this and you break your neck." Now, I'd heard that line repeated by coaches (and myself) often enough but I'd never thought it as I went into a jump. I made the 1.5 successfully, just as I had lots of times before, but it felt awful and I never did any serious tumbles again.
For a serious gymnast, they've been through that moment many times. Sometimes when their body wasn't doing as well as normal, sometimes when something distracted them at the vital moment. But the tough ones like Biles ignore it, and can keep ignoring it for years.
For a top gymnast, not being in the right headspace is a potential physical disaster. It's not like the marathon runner who sprains an ankle but decides to hobble home an hour late or the cyclist who carries his bike over the line in last place. Toughing it out mentally isn't good enough, if you feel off, it could be deadly and Biles has dealt with a lot over the past couple of years - so if she feels that the focus isn't there, she has to stop.