Well, space probes use a combination of command and on-board sensors, generally. A rocket tosses the probe in the general direction of the heavenly body, that’s pre-programmed. The probe is tracked by the deep space network, and mission control sends it course corrections periodically. If it has to land then it will use a radar or laser altimeter to track its own descent, and then do preprogrammed stuff at various heights.
Landing is generally harder than just hitting something, though. /cough/Schiaperelli/cough/.