When defining abstract algebraic structures (like monoids, groups, etc...), are there some constraints on the shape of the axioms, for the structure to have good properties that we implicitly use in many proofs (like behaving well with respect to morphisms and quotients)?

For instance, is the following axiom acceptable, in a structure equipped with a unary function $f$ and a binary operator $\circ$: $$\forall x, \text{ if }x\circ x=x\text{ then } f(x)=x.$$

More specifically, does it make sense to study varieties generated by (subclasses of) such classes of objects, even if the class of structures so defined is not a variety, since this axiom is not an equation?