To stop things from moving you want the Immobilized condition, most commonly applied through the Grabbed condition, which can be done with the Grapple action.
Attack of Opportunity makes it risky to move, as doing so might make the enemy take additional damage.
you could also trip them to reduce how far they could move, coupled with attack of opportunity gives them a risk.
or you can trip AND grab them, in which case they would have to remove grappled before attempting to stand which means a minimum of 2 actions not moving away.
there's also abilities and spells that create difficult terrain, some that push, some that make obstacles.
there's alchemical bombs, spells and abilities that reduce movement speed.
it's very hard to completely lock down movement. best you can do is make it difficult to move, and if they choose to move anyways, they're doing less damage
Other Reactions like Stand Still, Disrupt Prey and Implement's Interruption also come into this, fir different classes. AoO is the most widely used reaction to movement, but hardly the only one.
Doubt AoO doesn't are feat for the major part of classes.
AoO is available on a lot of classes. Especially ones that would be trying to keep enemies from moving away. Even more classes have something that is similar to it.
Fighter gets AoO automatically.
Champion can get it from class feats.
Swashbuckler can also get it from class feats.
Oh, and Magus can get it from class feats.
Barbarian can get AoO as well as at least one feat that is slightly similar (Mage Hunter).
Monk gets Stand Still, which is pretty equivalent to AoO.
Ranger gets Disrupt Prey which is AoO but only against the prey target.
Thaumaturge can get something similar with Weapon Implement.
Those are the ones that I can remember immediately.
All of those generally make moving a risk. I think they all will actually prevent movement, but only on a critical hit.
To actually prevent movement, you need to use the Immobilized condition.
The easiest way to give an enemy the Immobilized condition is with the Grabbed condition - which is done using Grapple. Have a free hand or a weapon with the Grapple trait, make an Athletics check with the Attack trait (so that it uses and contributes to Multiple Attack Penalty), if you beat their Fortitude DC, then they are Grabbed and Immobilized.