But how did it fire if the hammer was not even cocked?
As someone pointed out up above, the P9 is based on a gun that had the usual modern feature of having a firing pin block - a linkage that holds the pin immobile unless the weapon is cocked with the safety off. It’s surprisingly complex to do one of these right sometimes - this safety system was troublesome and unreliable in the parent design and apparently Springfield decided to remove the system entirely.
If you don’t have a firing pin block, what happens on an uncocked gun with an exposed hammer is that it hits the ground hammer first. The uncocked hammer is in contact with the back of the firing pin. The energy of the hammer’s collision with the ground is transmitted to the firing pin, which flies forward. That hits the primer and sometimes it’s enough to set the cartridge off.
The 1911 isn’t immune to this problem as the original design does not allow the safety to be engaged with the hammer down and it had no other firing pin safety. Colt introduced the ‘Series 80’ design that added a firing pin safety - which changed the trigger feel of the design - and most of the industry has followed suit. The ‘Series 70’ and earlier designs without a firing pin safety are still offered but they are increasingly relegated to specialist uses in terms of market share.