A player can defend against mobs by placing cobwebs against a ledge. The cobweb prevents jumping so mobs won't go up the ledge. Spiders are an obvious exception to this defence but endermen are surprisingly also unimpeded
Steps to reproduce:
Dig a 1 block hole and place a cobweb inside it
Use an enderman spawn egg on the cobweb to seemingly trap the enderman
Wait for the enderman to walk out or lure it out with an endermite
The same kind of happens for sweet berries however the enderman will not find a path on its own. It can however still be pushed out of the hole.
Hello tholleman!
While reproducing, it seems to me that the enderman does get stuck. Try dropping him from a height, or putting him in a large field of cobwebs! However, the jumping out is definitely a bug, and is probably a hitbox issue (as a result of the enderman's champagne flute-like hitbox.)
Hope this helps you!