How to do that? I know it is possible in snapshot 15w42a.
So i change my version to that but i dont have my world in 1.21 there, how i change the version of my *world* into the snapshot,to get mending and infinity and then go back to the latest version?
There is no way to downgrade a world from 1.21 to such an old version - you'll completely run the world if you did because the save format has changed so much they simply can't read it (even downgrading by a single version can completely regenerate the world, and since the game automatically saves anything that has been changed it will overwrite the original data).
However, what you can do is open to LAN and enable cheats, then switch to Creative mode, which allows you to put any enchantment on any item (you can use the anvil or commands to do this, the latter being more flexible but the anvil is simpler). Cheats will only be enabled until you reload the world but any changes made will remain in effect (so be sure to switch back to Survival mode).
(also, I personally disagree with this exclusion and would remove it myself if I played newer versions, it seems that it was done to nerf players exploiting Punch-Mending-Infinity bows to boost elytra; rocket boosting was added as a legitimate means to do so in the very same snapshot that made Mending and Infinity mutually exclusive. Also, why 15w42a? These changes were implemented in 16w50a, a snapshot for 1.11.1, so you could just as well have used any full release between 1.9 and 1.11 and these versions are much more stable than snapshots (they would still ruin your world though)
How to do that? I know it is possible in snapshot 15w42a.
So i change my version to that but i dont have my world in 1.21 there, how i change the version of my *world* into the snapshot,to get mending and infinity and then go back to the latest version?
I dont want to open a new world, i just need to get this broken bow in my world and then go back to the original version.
Im on a pc java edition
There is no way to downgrade a world from 1.21 to such an old version - you'll completely run the world if you did because the save format has changed so much they simply can't read it (even downgrading by a single version can completely regenerate the world, and since the game automatically saves anything that has been changed it will overwrite the original data).
However, what you can do is open to LAN and enable cheats, then switch to Creative mode, which allows you to put any enchantment on any item (you can use the anvil or commands to do this, the latter being more flexible but the anvil is simpler). Cheats will only be enabled until you reload the world but any changes made will remain in effect (so be sure to switch back to Survival mode).
(also, I personally disagree with this exclusion and would remove it myself if I played newer versions, it seems that it was done to nerf players exploiting Punch-Mending-Infinity bows to boost elytra; rocket boosting was added as a legitimate means to do so in the very same snapshot that made Mending and Infinity mutually exclusive. Also, why 15w42a? These changes were implemented in 16w50a, a snapshot for 1.11.1, so you could just as well have used any full release between 1.9 and 1.11 and these versions are much more stable than snapshots (they would still ruin your world though)
TheMasterCaver's First World - possibly the most caved-out world in Minecraft history - includes world download.
TheMasterCaver's World - my own version of Minecraft largely based on my views of how the game should have evolved since 1.6.4.
Why do I still play in 1.6.4?