Your template doesn’t use int or float to convert the output of the states() function to a numeric value. That means it’s comparing string values, as opposed to numeric values. That explains the results you see.
Use the float filter to convert each string value to a numeric and then the comparisons will work the way you expect.
Don’t attempt to convert the values in that one. A string comparison happens to be acceptable in this very specific use-case where the two strings represent time.
Except that the input_datetime will return a string value including seconds.
As Taras says the string comparison will still evaluate correctly but it will be : -
‘22:01:00’ <= ‘22:02’ returns true but
What about ‘22:01:00’ <= ‘22:01’ ???
You would probably be fine and never notice if there was a minute difference but the OCD in me will instead use : -