Case 1: if a two-rakah nafl is begun and invalidated, the Hanafi makeup is two rakahs.
Case 2: in a four-rakah nafl where the first pair has been completed with its sitting and the later pair is invalidated, Abu Hanifa and Muhammad require two-rakah makeup, while Abu Yusuf requires four.
The distinction turns on whether the first pair reached completion.