Exactly this. Lets say you catch a Kakuna lv 20 and a Scyther lv 7. The Scyther is a better choice but is not as strong as the Kakuna or as high level as the Kakuna.It has to do with the pokemons level and stats ect... stuff like that.
Always save before you enter the contest, and that way, you can keep trying until you've won.