COUNTIF requires a range (first param) so you can't embed an inline array like that.

Formula: copy to clipboard
=SUMPRODUCT(--(E4:E7-D4:D7=2))
confirmed with Enter