The isostructural double perovskites Ba$_2$CuTeO$_6$ and Ba$_2$CuWO$_6$ are shown by theory and experiment to be frustrated square-lattice antiferromagnets with opposing dominant magnetic interactions. This is driven by differences in orbital hybridisation of Te$^{6+}$ and W$^{6+}$. A spin-liquid-like ground state is predicted for Ba$_2$Cu(Te$_{1-x}$W$_x$)O$_6$ solid solution similar to recent observations in Sr$_2$Cu(Te$_{1-x}$W$_x$)O$_6$.