What the heck just happened?
Since this has basically never happened before let's rule out the possibilities.
If those are true then the only feasible possibility was that it glitched. It's not that far fetched since you claim that you were running around pressing random buttons and I'm no expert but that looks like it could put a significant amount of strain on your game. Normally that would lead to a damaged game but absurdly, it led to 300 ultra balls.
The other possibility is that you always had 300 ultra balls and had temporary memory loss
There really isn't any other way to answer this question because the conditions are too unclear and we don't know what variables caused the reaction, whether it be the sequence of actions your character commited or the buttons that you pressed. This is about as coherent of a response you will get
I hope I helped and even if I didn't atleast you have ultraballs
300 Ultra Balls? Whaaattt? The most likely thing that could of happened was that you probably might of pulled of a glitch that nobody knew about, or your game cartridge might of had a little freak out and gave you 300 Ultra Balls. Or, your copy may not be a legit one, and might not of been made very well. Other than those things I have no idea what might of happened. What game were you playing? what button did you press? What did you do before you got the Ultra Balls?