Hinata, after seeing the person she loves (Naruto) get rekt by Pain, stepped in, to fight Pain and showcased her skills of the world-renowned Hyuga clan’s fighting style the “Gentle Fist”.
She wanted to save Naruto and didn’t care who her opponent was.
She was able to land one hit on Pain but only because Nagato’s condition got worse and Pain got hit.
Hinata’s objective wasn’t to defeat Pain (Nagato), but to save Naruto from Pain but to do that she had to risk it all.
She almost died to protect Naruto but she didn’t care about herself and tried her best in saving Naruto. This reaction of Hinata influenced Naruto to turn into 9-Tails form and go into a rampage later on.