Anything that is extra or not needed is unnecessary. Wearing long underwear in July is an unnecessary precaution against being cold.
If you don't need something, it's unnecessary. You take an unnecessary risk if you get in the car and don't bother to fasten your seatbelt. Driving your car when you could ride a bike instead is an unnecessary use of gasoline. If you keep dropping you pen in class, your teacher might say, "That's unnecessary." Walking your dog with two leashes is definitely unnecessary. That's obvious, but lots of times it's hard to tell what's necessary and what's unnecessary.