I noticed this is other OSes as well, but most visibly in Ubuntu Linux. Whenever a good request is made, it is computed practically instantly. However, whenever a bad request is made (a bad password, a non-existent command, etc) it takes a few seconds before it lets me try to give input again. Is this some kind of security measure?
I agree with kyleN's answer regarding why typing a wrong command in terminal takes longer then starting an existing program.
A pause after entering a wrong password, however, is a completely different matter - this delay is introduced intentionally to prevent brute-force password attacks (i.e. trying thousands of passwords a second until one matches). Adding a small delay when an incorrect password is entered doesn't affect usability for "real" users but makes such attacks completely impractical. So yes, in this case it's a security measure.
Generic answer to generic question: a 'bad request' is determined to be 'not found' only after searching all possibilities for a match and finding none. However, when something is 'found', it is usually specific enough to be found very quickly, and not all possibilities need to be checked before determining it is 'found'.
The delay after entering a wrong password is done deliberately for security reasons.
The delay when entering a wrong command line into the terminal is a side-effect caused by Ubuntu having some extra mechanics that trigger when a command isn't found. Instead of just printing "command not found", Ubuntu searches it's repository to see if the command you typed is provided by a program you don't have currently installed and then gives instructions on how to install it. That search can take a second or two.