Here's why:
* Don Quixote is a chivalrous knight errant who battles windmills and imagines himself on grand adventures. Shrek is a grumpy ogre who also seeks a grand adventure, albeit one with more practicality.
* Sancho Panza is Quixote's loyal sidekick, a simple, pragmatic farmer. Donkey is Shrek's constant companion, a talkative and often comical donkey.
While not exact replicas, the core dynamic of a grumpy, idealist hero and his loyal, practical companion is mirrored in both pairs.