Pokemon games have rules that limit the experience to a certain extent, like not being able to catch a wild Pokemon after it faints, not being able to withdraw from Trainer battles, or having to progress through the story as intended. For example, Pokemon Brilliant Diamond and Shining Pearl won't let players access some areas until they acquire a specific HM to use and the respective Gym Badge to unlock it.
Read more on gamerant.com