Does a hash function necessarily need to allow arbitrary length input?
Is it necessary for a hash function to allow arbitrary length inputs or not?

Of course not.  SHA-256 is limited to inputs of 18,446,744,073,709,551,615 bits or less; it is not defined for larger inputs; SHA-256 is not disqualified from being considered a hash function because of this limitation.