Why hydrogen behaves both as a halogen and as an alkali metal?

The dual behaviour of hydrogen is attributed to its electronic configuration i.e., Is1. Because of this hydrogen has equal tendency to either gain or lose one electron in order to achieve stable configuration.