Black and white wires coming out of wall are both hot
That's a switch loop. Bog standard. Perfectly legit until recently. The white should be unswitched hot, and the white should have marking of tape, paint or heat-shrink in a hot color (but often does not.)
You need to find the box that the switch loop comes from, where you will find its white connected to a black, and where there is normally also a white neutral.
Color does NOT imply function in cables. Color may guide you, but not all whites are neutrals.