I entered a wrong password on my lockscreen today, and saw it took around 1-2 seconds for it to shake and prompt for a retry. However, if I enter the password correct, it takes fractions of a second to verify. Is there a reason for this? Shouldn't an equality check take the same time regardless of what was entered?
It is not the actual password check that takes the time. An equality check (which is not what is done here) takes <1 millisecond on a modern computer, so it's not something you can experience.
The delay is actually introduced by purpose by Apple programmers, so that an incorrect attempts results in this slight delay. It is an intentional delay which is purposefully inserted.
The reason for having the delay could be to alert the user that the password entered is incorrect, and to "pause for second" and try again with more precision. This way the user cannot quickly type lots of differents things, but will have to wait a bit between each attempt.