If the ender dragon is riding a mob or armor stand it will push the entity away with its melee attack. The entity will take a lot of knockback, and because the ender dragon is still on top of it, it will continue being yeeted until it dies or reaches the edge of loaded chunks. This can be reproduced as follows:
1) Open up or create a creative world
2) run the following command in chat:
/summon minecraft:elder_guardian ~ ~ ~ {Passengers:[{id:"minecraft:ender_dragon"}]}
3) Both entities will immediately teleport to the edge of loaded terrain, usually to the south and somewhere up in the sky. (The elder guardian will quickly be killed by the dragon unless it is summoned as Invulnerable or the like, although the changes to mount points in the 1.20.2 snapshots seem to have made this less consistent.)
This probably isn't widely noticed because the ender dragon is (to my knowledge) the only mob that automatically yeets everything in its hitbox, but I imagine it could also apply to mobs from mods which do the same thing. In my opinion the best way to solve this would be to prevent all entities from colliding with their own mounts, as well as preventing the ender dragon from melee attacking its own mount.
Linked issues
is duplicated by
Attachments
Comments

still in 1.8.1
It seems that this will not happen when the ridden Mob has no AI:
/summon EnderDragon ~ ~ ~ {Riding:{id:Zombie,NoAI:1}}
But still, he tries to fly and his animations are faster than normal.
Wait, I experimented now with this bug and I think I have an Idea, why this is happening:
The Enderdragon pushes mobs away when he attacks. I guess what is happening, that the Enderdragon pushes the ridden mob. Because he is attached to him, he will also get pushed in that direction. That's why no AI will not affect this "pushing", because when a mob has no AI, it will not be affected with gravitation or simmelar stuff. The Dragon will not push these.
In a nutshell, this is not a bug. With these results I can kinda say, that this is intended.
I couldn't reproduce the prb with the new ridding code.
This problem is also surely due to how ridder/ridden AI are interacting and might solve itself once some global changes to the AI are implemented.
Until then, the ticket is closed as "Couldn't reproduce".

The commands do not work for the latest snapshots anymore, please update them:
/summon Fireball ~ ~ ~ {direction:[0d,0d,0d],Passengers:[{id:"EnderDragon"}]}
/summon WitherBoss ~ ~ ~ {Passengers:[{id:"EnderDragon"}]}
/summon Blaze ~ ~ ~ {Passengers:[{id:"EnderDragon"}]}
Confirmed for
15w47c With other mobs, like Blaze or WitherBoss, but I agree with @unknown, this seems invalid
Can confirm for 1.9. When the fireball hits a wall, the EnderDragon is back to his old AI, flying around the player.
Made a duplicate for 1.16.4 pre 1 because it's present their too. (dupe report was closed)
Can confirm in 20w46a.

I finally figured out what's actually going on so I updated the name/description accordingly.
Can confirm in 21w05b.
Can confirm in 1.16.5 and 21w08b.
Can confirm in 21w17a.

May relate to MC-19163.

That issue is totally unrelated. This issue deals with the ender dragon's specific damage-dealing implementation, which is not at all related to how player actions are handled when they are riding something.
Confirmed for 1.8.