It is a simple question. But, I want to make sure I am not missing any crucial assumptions. Is this
$A = (\hat{Y} - Y)^2$
same as
$B = (|\hat{Y} - Y|)^2$
Main concern: If $A$ returns negative inside the parentheses, we are squaring it, so it becomes positive. And, $B$ takes the absolute value and then squares it. At end, $A$ and $B$ return the same answer, using different mechanisms to "enforce" positivity. If $\hat{Y}$ and $Y$ are real numbers, does that makes $A$ and $B$ same?
Yes, they are the same. You can use a syllogism:
If $\hat{Y}$ and $Y$ are real numbers, then $\hat{Y} - Y$ is a real number
If $x$ is a real number, then $x^2=\left(|x|\right)^2$
So, if $\hat{Y}$ and $Y$ are real numbers, then $\left(\hat{Y} - Y\right)^2 =\left(\left|\hat{Y} - Y\right|\right)^2$