IKEv2 mutual authentication step
why just signing Ni and Nr is not enough?

Because we want to make sure that man-in-the-middle can modify (or hijack) the initial messages without being detected.
Consider this attack:

Alice sends an IKE_SA_INIT request to Bob

Mallet intercepts that message; he forwards his own IKE_SA_INIT message to Bob, using Alice's Ni value, but his own KE payload

Bob replies with an IKE_SA_RESP message, which his Nr value.

Mallet intercepts that message; he forwards his own IKE_SA_RESP message to Alice, using Bob's Nr value, but his own KE payload


Essentially, Mallet is establishing two separate IKE connections, one with Alice and one with Bob.
Alice then authenticates herself; if she just signed the Ni, Nr values she saw, Mallet could just resend that signature to Bob (which saw the exact same Ni, Nr) values, and so Bob would assume he's talking to Alice.
By appending the prf(SK_pi, IDi') value, this is not possible (because Alice and Bob don't have the same SK_pi value)