Such powers are called Yogic Siddhis (occult powers). A highly adept Yogi, by severe practice of Yoga, can achieve those powers.
The mighty Yogi having attained, through pranayama, tho eight sorts of psychic powers, and having crossed the ocean of virtue and
vice, moves about freely through the three worlds.
Then gradually lie should make himself able to practise for three ghatis (one hour and a half at a time, he should be able to restrain
breath for that period). Through this, the Yogi undoubtedly obtains
all the longed-for powers.
The Yogi acquires the following powers :—vakya siddhi (prophecy), transporting himself everywhere at will (Kamachari),
clairvoyance (duradristhi), clairaudience (durashruti), subtle-sight
(shukshma-drishti), and the power of entering another’s body
(parakaypravesana), turning base metals to gold by rubbing them with
his excrements and urine, and the
power of becoming invisible, and lastly, moving in the air.
From Shiva Samhita's Chapter 3
So, becoming invisible, going anywhere at will etc. are all Yogic powers obtained by severe practice of Yoga, Pranayama under the guidance of a Guru.