Like even if you throw a master ball at like a really powerful legendary pokemon, there is a 100% that the pokemon will be caught right??
Yes, you are right but it doesn't work on a trainer's pokemon
The chance is not 100%, even though most people think it is. The actual chance of NOT catching a Pokémon is 1 in 65,355 or 0.0015%. However, this is very small. It is about 8 times of the chance of finding a shiny Pokémon! You don't want to worry about it.
Source: http://pokemondb.net/pokebase/144084/my-master-ball-didnt-catch-my-giratina?show=144084#q144084
Hope this Helped!!!