It's actually quite a simple concept, it gets confusing the more you think about it.
Say you have
charmander level 30
charmeleon level 30
if you find a wild pokemon and defeat it, with either one. you will get the same exp amount.
however,
charmander needs less to get to the next level.
charmander: needs 4000xp to level 31
charmeleon: needs 6000xp to level 31
(these numbers are not accurate, they are just written in a way to better understand the concept)