it's not entirely random, but there is an element of RNG (random number generated). Think of it this way, say for example you've got a 70% chance to catch with ultraball -- just made up this number for sake of argument. You should catch the pokemon 7/10 tries; however, that doesn't mean you are guaranteed to catch it.
Similarly, even if your odds are only 10% with pokeball, that doesn't mean you won't catch it. Sometimes you get a good "roll" with 10% odds and have success whereas sometimes you get a bad "roll" with 70% and fail. It's all a matter of probabilities.
Hope this makes sense.