How do pilots know that the switch/knob they just switched on/off actually did what it's supposed to do?
Depends on the system in question, but typically the following indications will serve as a means to verify that a system is functioning correctly.

Activation lights - some cockpit switches will illuminate when commanded by crew.  Granted this only can serve as an indication that the switch was engaged.

Indicator lights eg landing gear position lights, etc - remote switches on mechanical systems which are activated when said system are in a required positions or functioning.  The switch then can illuminate lights on an instrument panel.

Mechanical indicators eg flap position indicators - system provides either a mechanical or otherwise signal back to an indicator which mechanically moves in unison with with the system.

Information Displays - integrated flight decks and multifunction displays take inputs from similar remote mechanical, thermal, pressure and electrical inputs from aircraft systems and display either textual or graphic indications on displays.

Kinsethetic reactions - eg lowering flaps will cause the airplane  to decelerate and pitch up, landing gear actuation will cause sounds, vibrations, wind noises, etc.

Correct system function - eg autopilot mode engaged and the airplane is doing what the crew expected of the command.