Mentally out of it

For the last 4 months I have been applying to PhD SWE intern role, made it to team matching for Meta and still got rejected, I was so sure I was going to make it past team matching, but I guess not. I spoke to three team who liked me and I liked the last two teams but still got a reject. It took me 2 months to grind leetcode, along with being a TA(teaching assistant) doing research and all of that. After the rejection I was totally out of it, discouraged, but some how I managed to keep applying and got one interview call back for stripe. I just finished the 3 round(onsite) and I feel I didn’t do my best for the integration part (ML integration) I ran out of time, I panicked but I knew what I was supposed to do but couldn’t do it. Now I am thinking if I would even make it past this round and get an offer.

I didn’t know it took this much mental strength for interviews, those who applied and finally got an offer how did you encourage yourself to keep pushing?

Just to add, the meta role is for a PhD intern, and meta requires all PhD intern be matched before they extend an offer and as such many people get stuck at team matching.