Outdoor direct burial wire can be used outdoors safely.
However indoor wire should not be used directly outdoors unless the indoor wire is placed in conduit.
I have used indoor wire outside but ran the indoor wire inside metal conduit to protect it from the sun and other weather elements.
Indoor wire can also be buried outside as long as the indoor wire is placed in some metal or plastic conduit.
For metal conduit to be buried with the indoor wire inside it must be sealed from water penetration.
Plastic conduit is best for underground electrical runs though as it does not rust away like metal can.
When indoors it's better to use indoor wire as it's easier to work with than outdoor wire.
Outdoor wire that is grey in color can be installed outdoors underground without conduit.
The grey outdoor electrical wire also known as direct burial romex can installed underground without being put into conduit.
The outdoor romex wire can also be instaleld outdoors without conduit such as on walls, poles etc.
However if installed outside I would recommend installing the outdoor wire inside conduit as from my experience of having outdoor grey romex directly in the sunlight has caused the insulation to harden up and it turned a brown color.
Then the insulation can degrade and come apart.
So It's best to run the outdoor wire inside some plastic or metal conduit to protect it.
It also makes it less prone to copper theft as well.