Mending never comes from an enchanting table. It is a treasure enchantment, which leaves you four routes: villager trading, fishing, loot chests, and raid rewards.
Villager trading is the reliable one
Turn a villager into a librarian by placing a lectern near an unemployed one. Check the first trade slot: if it is not Mending, break the lectern, place it again, and the villager re-rolls its trades. Repeat until Mending appears, then trade once to lock it permanently.
This works on any villager that has not yet traded with you. Once you have traded even once, the offers are fixed forever, so check before you buy anything.
Fishing
Enchanted books turn up in the treasure category, and a rod with Luck of the Sea III improves the odds. It is slow and random, but an AFK fishing farm produces books unattended, and you will pull other useful treasure alongside them.
Loot chests
Strongholds, mineshafts, dungeons, desert and jungle temples, ancient cities and woodland mansions can all contain enchanted books. It is worth opening every chest you pass, but do not plan around it.
Why everyone wants it
Mending turns experience orbs into repairs on whatever you are holding or wearing, at two durability per experience point. Combined with Unbreaking III, gear effectively stops wearing out. It is the difference between replacing a pickaxe every few sessions and using the same one for a year.
One conflict to remember
Mending and Infinity cannot coexist on a bow. Infinity gives endless arrows; Mending gives a bow that repairs itself. Most players take Mending and carry a stack of arrows. Details and every other conflict are in the enchantment list, and the calculator blocks clashing picks automatically.