It's possible to duplicate the inventory of donkeys and mules by unloading them (e.g. by sending them to the nether) while the inventory is opened.
Here's how you can reproduce it:
1. Get a donkey/mule with a filled inventory.
2. Open the inventory and leave it open.
3. Send the mob through a nether portal or unload it any other way. (Since you still have the inventory open you will need a second player or a water stream to move it)
4. Take items out of it's inventory and close it.
5. Go to the nether and find the donkey/mule with a filled inventory again.
To fix this the inventory should close when the donkey/mule gets unloaded.