Not understanding the wrong logic in this proof The problem is :

Suppose $a,b \in Z$. If $a^2 + b^2 $ is a perfect square, then $a$ and $b$ are not both odd.

My question is why can't I answer like so:

Proof by Contradiction -- Suppose $a^2 + b^2 $ is a perfect square, and $a$ and $b$ are both odd. Let $a = 5$ and $b = 7$. Then $5^2 + 7^2$ is a perfect square. $5^2 + 7^2 = 74$, so 74 is a perfect square. However, we know that 74 is not a perfect square. Therefore there is a contradiction. So if $a^2 + b^2 $ is a perfect square, then $a$ and $b$ are not both odd.
The reason why this proof is invalid is that the quantifier is not included.

The preposition should be:

$\forall a,b \in Z, $ if $a^2 + b^2$ is a prefect square, then $a$ and $b$ are not both odd.

The counter-positive of this notion is:

$\forall a,b \in Z, $  if $a$ and $b$ are both odd then $a^2 + b^2$ is not a prefect square. 

So one should not pick up specific example to show the counter-positive holds.

EDIT: to clarify logical reason, consider the following example:

The background is that $R$ is an algebraic structure.

The preposition is: $\forall a,b \in R$, if $a\times b$ is $0$, then $a = 0$ or $b =0 $. 

What's the counter-positive of this statement?

It should not be: $\exists a,b \in R$, if $a \neq 0$ and $b \neq 0 $,$a\times b$ is not $0$.

Because if $R = \mathbb Z/6\mathbb Z$, then $a = 2$ and $b =2 $, then   $a\times b = 4$ is not $0$. But in $R$ there indeed pair$(2,3)$ such that  $2\times 3 = 0$ but $2$ is not zero and $3$ is not zero. Therefore it should not be an counter-positive for the preposition.

One thing  which should be borne into my mind is that when one counter the preposition, the quantifier should not change otherwise one may be trapped into logical loophole.
hint: consider $\mod 4$ . A square can only be $0,1 \mod 4$. Note that this is a proof that for the sum of two squares to be a square again, both can't be odd. For your proof, you are incomplete hence wrong because your argument is true only for the case $a = 5, b = 7$ but you don't cover all cases for $a,b$.