Java Edition:Item with Infinity and Mending
The Infinity and Mending enchantments used to not be mutually exclusive. They were first available together in 15w42a (a 1.9 snapshot) when Mending was introduced and were changed to be mutually exclusive in 16w50a (a 1.11.1 snapshot). An oversight in that snapshot however still allowed Mending to be applied to items with Infinity (but not the other way around), but this was quickly rectified in 1.11.1, making 16w50a the last version they could intentionally be applied together on the same item. This was done as the developers considered the ability to shoot infinite arrows and repair the bow indefinitely was overpowered.
Obtaining
Intentional Obtainability
These methods work from 15w42a to 1.11, the period during which it was intended for these enchantments to be compatible. These methods will also partially work in 16w50a, notably where Mending is applied to an item with Infinity. Attempting to apply Infinity to an item with Mending will not work in 16w50a.
Bow
Bows could be obtained with Infinity and Mending in a variety of ways. These include using an anvil to combine a bow with Infinity with a bow with Mending, combining a bow with Infinity with an enchanted book with Mending (or vice versa), and combining a bow with an enchanted book with both Infinity and Mending. These bows could also be obtained as treasure loot from fishing. Notably, bows from fishing will not have a repair cost, which is impossible through anvil combination.
Enchanted Book
Enchanted books with Infinity and Mending can be obtained in very similar ways to bows. Using an anvil to combine an enchanted book with Infinity with an enchanted book with Mending, or vice versa will combine the enchantments. These books were also available as treasure loot from fishing. They could also be found rarely as structure loot in jungle pyramids or stronghold libraries. For a very brief period from 15w42a to 15w43c, these books could also be found in desert pyramids, mineshafts and dungeons. Notably, enchanted books from structure loot and fishing will not have a repair cost, which is impossible through anvil combination.
Grindstone Enchantment Duplication
Using grindstone enchantment duplication from 24w10a to 24w11a (1.20.5 snapshots), it is possible to transfer enchantments from one item to another while bypassing compatibility checks for the enchantments on the items.
Order of Enchantment
There are technically two separate bows obtainable in these versions that are identical in behavior but have different NBT data. The player can obtain a bow with Mending first and Infinity after or Infinity first and Mending after.
Additionally, the other enchantments for a bow (Punch, Power, Flame, Unbreaking, or one random enchantment) can be combined in hundreds of different permutations. All of these bows will only be creatable in this time range.
Number of Possibilities
Normally, in 1.9 there are 6 available enchantments for a bow: Punch, Power, Flame, Unbreaking, Infinity, and Mending. To calculate the number of possible bows with different orderings of the enchantments factorial must be used. 6! = 720 different possible enchantment combinations when you have all the enchantments. But we can also calculate having some of the available enchantments for a grand total of 6!+5!+4!+3!+2! = 872 different discontinued bow with various enchantment arrangements. Later, when Curse of Vanishing and Curse of Binding are added to the game they can be applied to any of the 872 bows.
Number of Possibilities with Any Enchantment on any Item
Additionally, using any enchantment on any item you can append Infinity and Mending to a bow that has a discontinued enchantment such as Protection.