For me, pokémon obey their trainers for a variety of different reasons, just as humans obey the rules (to a point) for a variety of different reasons.
First of all, though, I do have some pokémon that resent being captured, and not many of them transform to obedience-mode after a while with their trainers. Depending upon the way that you come up with, the same may or may not be logical for your characters. If you go with a purely free-will kind of thing, it's likely that your characters will encounter some pokémon that choose not to obey.
For my own 'fics, pokémon are technically under no obligation to fight for their trainers. Most do, though, for one or more of several reasons:
1. It's just in the pokémon's nature to enjoy getting ordered around. This is true of some humans; there are people who are much more comfortable following orders than making decisions of themselves. Probably a much stronger impulse in pokémon with a hive or pack mentality, where there's a higher-up that usually does the dispatching. If a trainer captures a pokémon with a natural position of authority, like the queen of a hive or the leader of a pack, they're much less likely to obey, though.
2. In the interest of becoming stronger. If a pokémon is captured, it likely was looking to be anyway, and that means it's interested in traveling and improving its battle skills. Generally a good way to do this is hook up with a strong trainer and let them do all the legwork of continent-crossing and trainer-finding; the free heals and experience against a variety of kinds of opponents also makes this approach more lucrative than just wandering by oneself. However, if a pokémon feels that a trainer is only holding it back, it obviously won't obey.
3. Loyalty or a sense of duty. If a pokémon and trainer have grown up together or otherwise developed some sort of relationship, it's possible that the pokémon will obey because it wants to repay its trainer or just help him or her out.
4. Fear of punishment. In the case of an abusive trainer, pokémon may be "broken" and follow only because it has little will to act otherwise.
5. Control by some external measure. Shadow pokémon, some Rocket or otherwise altered pokémon (and all pokémon in one of my 'fics) may be under the influence of some device or process that causes them to obey unswervingly. This often leads to a detrimental lack of free will.
6. For the fun of it. For some pokémon, battle is just a game. They don't particularly care if they win or lose, but traveling the region and hanging around with some pokémon from far away is quite the adventure, and they're glad to be along for the ride.
Within these all there are different degrees of obeying and not. Some pokémon will take an action against orders if it believes that this will lead to a better outcome, regardless of usual loyalties. Some will want to mess with their trainers, or just go their own way for a while. It's all down to personality and individual motivation with that.