You're just really unlucky
Just keep soft resetting your game(if you don't know how to soft reset, it's L+R+Select) until you finally catch it. Buttons don't do anything, btw. I hate when you try to catch legendaries, it takes too long :P. If you're getting really tired of using ball after ball after ball, just end it using the master ball after you soft reset once more, so you don't lose your ultra balls.
Hopefully this answers your question
Hope I helped!(ish)