Actually you can check source code of Hydra, it's opensource.
But, using simple words, hydra is working through pattern mathing. As far as I remember, when I used Hyndra, I needed to enter "Success pattern" or something like this. This pattern is HTML on the "Login is success" page and if hyndra found this pattern, after login request was sent, then login credentials are found.