When do we have $(x y)^2 = x^2 y^2 $? I just started thinking about algebra so this might be a trivial question.
Anyway,
Under what conditions do we have
$$(x y)^2 = x^2 y^2 $$  ?
Does it need to be a group ?
Or a groupoid ?
Or a monoid ?
Is powerassociative sufficient ?
etc
Im not sure what the neccessary and/or sufficient conditions are.
Or how to prove them.
I only know that
$$(xy)^2 = xyxy $$
I need to understand this to be able to get further.
Thanks in advance.
 A: I think that asking under what conditions does a magma satisfy
\begin{equation}
(xy)(xy)=(xx)(yy)
\label{eq:semimedial}\tag{$*$}
\end{equation}
(an equivalent formulation), is a bit like asking under what conditions does it satisfy $xy=yx$: it just does or does not satisfy.
Of course what you're asking is whether or not is \eqref{eq:semimedial} a consequence of some set of other well known identities.
I suspect there is no positive answer that you would find interesting, except for the case of commutativity together with associativity, since that is an obvious case.
You already have from a comment that commutativity is not strictly necessary, since a right-zero semigroup works (that's the example given by Arturo Magidin); analogously, a left-zero semigroup also works.
Easier still would be a null semigroup (in which there is an element $0$ such that $xy=0$ for all $x,y$), but this one is also commutative.
Another trivial sufficient condition is the case of idempotent magmas (satisfying $xx=x$);
this gives you a lot of examples.
The example of a variety that seems to me is very close to the one defined by \eqref{eq:semimedial} is the one of Medial magmas, definable by the equation
\begin{equation}
(xy)(uv)=(xu)(yv)
\label{eq:medial}.
\tag{M}
\end{equation}
All you have to do is to replace $u$ with $x$ and $v$ with $y$, and you get \eqref{eq:semimedial} again.
For that reason, and for want of a better name, I would call semi-medial to the class of magmas satisfying \eqref{eq:semimedial}.
It is very easy to come up with medial magmas.
If $\mathbf R$ is a ring and $a,b \in R$, then, you get a new magma $\mathbf R^* = (R,\circ)$ by defining
$$x \circ y = ax + by.$$
It's easy to check that if $\mathbf R$ is commutative, then $\mathbf R^*$ is a medial magma.
In general, it's not commutative: $0 \circ 1 = b \neq a = 1 \circ 0$;
and also not associative:
$$(1 \circ 1) \circ 1 = (a + b) \circ 1 = a(a + b) + b = a^2 +ab + b,$$
and
$$1 \circ (1 \circ 1) = 1 \circ (a + b) = a + (a + b)b = a + ab + b^2,$$
so $(1 \circ 1) \circ 1 \neq 1 \circ (1 \circ 1)$, as long as $a^2+b \neq a + b^2$, and it's easy to choose $a, b \in R$ under this constrain, at least if the ring is not too small.
Notice that this also means that $\circ$ isn't even power-associative.
Since $a+b \neq 1$, most of the times, that means that $\circ$ is also not idempotent, and so it does not satisfy any of the conditions mentioned so far, except \eqref{eq:medial}.
So power-associativity is also not necessary.
But you asked if it were sufficient.
It isn't either.
Recall that a magma $\mathbf A$ is power-associative iff the subalgebra $\langle a\rangle_{\mathbf A}$ generated by $a \in A$ is associative, for every $a \in A$.
So consider the magma with the following multiplication table:

Here, we have
$$\langle a\rangle_{\mathbf A} = \{a\},\quad
\langle b\rangle_{\mathbf A} = \{a, b\},\quad
\langle c\rangle_{\mathbf A} = \{c\},
$$
The first and the last are $1$-element algebras which obviously satisfy any equation you want; the middle one, is the two-element null semigroup, with $a$ as a null element.
So $\mathbf A$ is, indeed, power-associative.
However, in $\mathbf A$ we have
$$(bc)^2 = c^2 = c \neq a = ac = b^2c^2$$
and therefore $\mathbf A$ is not semi-medial.
