Yes, there is certainly some risk, however, unless you were anchoring
in an area known for UXO (say, an old bombing range - plenty of them in shallow water
about the planet) the odds of your anchor hitting the exact wrong spot are really low - you’ll likely win the lotto a thousand times first.... I haven’t heard of an anchor triggering a detonation, but I have heard of plenty of UXO being bought to the surface by anchors dredges etc....
Even if you were anchoring on an old range, the risk is really low.
Where the real risk is, is when an UXO is bought to the surface and someone fiddles with it. A while back I spent a month in the island nation of Kiribati (Tarawa and Butaritari atolls) removing old ww2 jap, Brit and US ordnance from the reef and from within towns/villages - there were plenty of locals who were horribly disfigured from the UXO- the whole reason their government
had asked for assistance- the impoverished locals were digging up UXO and using a hammer and cold chisel to remove the brass fuzes for scrap metal value. They also had a habit of trying to dig holes by putting a shell in a small pit and lighting
a fire on top of it. To get back on topic, we did find 2 x 20Kg jap ground mines in good condition and likely fully functional biggest bang for the month was approx 1.5 ton NEQ ( big pile of UXO inside a hesco barrier we assembled it at low tide as far out to sea as we could, and popped it at high tide) . Biggest UXO found was a US 14 inch naval shell (retrieved from the edge of a village, our navy diver companions took that one well offshore
and blew it in deep water).