It varies based on the medium. Optical discs (DVDs etc) do it by altering the amount of light that is reflected/absorbed, hard disc and old tape discs use alterations of the magnetic field, and SSDs use a special kind of microchip that doesn’t require active power to retain its state
What they all have in common, is they have the ability to force a transition in their physical medium, which is persistent without power, and is consistent in the degree of change.
This means if I do the same thing to two different storage devices, they’ll both have the same state when I check them later. Depending on the device, I can then convert that state into 1s and 0s in a way that is consistent for all devices of that type
Latest Answers