Safety when modifying old electrical work
North American view, since OP is there. 

Wires in electrical wiring are NOT color coded

Your mistake there was assuming white meant neutral.   The simple fact is that electrical wiring is not color coded.  That's because cables are manufactured with only one set of colors - black and white for /2 cable or black, white and red for /3.  No matter what function the wire has, it must "make do" with the colors available in standard cable.  




Any colors you want, as long as you want black, white and maybe red.

There are only 2 color rules.  


Grounds are always and only, green, yellow-green or bare.  Those colors can only be ground. 
Neutrals can only be white or mid-gray, but that only applies if this cable has a neutral.  If this cable doesn't need a neutral, white can be a hot.  You're supposed to mark it with paint or tape, but previously you could skip it if the usage was "obvious". (to an electrician, heh). 


This last one is what bit you. 

Smart switches have special needs

You should have opened up your switch and investigated the wires that were available to you, before you bought the switch.  If you only see 2 wires (besides ground), they must be always-hot and switched-hot, because a switch can't work without those two. 

If your location doesn't have neutral, don't buy a smart switch that needs it. 

If your location doesn't have ground, ditto. 

You may hear things that tempt you to use ground for neutral or vice versa.  Don't. Neutral is not ground. 

There are smart switches that require neither neutral nor ground.  They may require at least one of the bulbs to be compatible LED, incandescent, or a capacitor-resistor bypass added. 

There are also other ways to work around the problem, such as smart switches that put a switching module up in the ceiling rose, then the wall switch effectively becomes a "remote" for the module.