This problem was studied by Fujita in his paper "Cancellation problem of complete varieties", Inventiones Mathematicae 64 (1981).
He showed that the obstruction to cancellation is caused by the Picard schemes, proving the following remarkable result (see Corollary 7 in the cited paper):
Let $M$, $V$ and $W$ be compact complex manifolds such that $M \times V \cong M \times W$. Assume that $M$ is projective and that $\textrm{Alb}(M)=0$ or $\textrm{Alb}(V)=0$. Then $V \cong W$.
In particular, cancellation problem has a positive answer for $M=\mathbb{P}^n$$M=\mathbf{P}^n$.
The condition on the Albanese variety is a necessary one; in fact, it is known that cancellation is not always true for abelian varieties.