This is true in the smooth case, assuming $j:Y\hookrightarrow Z$ is proper (inverse images of compact sets are compact; this holds for example if $Y$ is compact). It is a consequence of a more general fact, that pushforwards (or Gysin, or Umkehr homomorphisms) for proper maps commute with pullbacks. That is, given a transverse pullback square such as

$$
\require{AMScd}
\begin{CD}
X\cap Y @>{f}>> Y\\
@V{g}VV @VV{j}V \\
X @>{i}>> Z
\end{CD}
$$
where $j$ is proper, and a cohomology class $a\in H^*(Y)$, we have
$$
i^*j_!(a) = g_!f^*(a) \in H^{*+\operatorname{dim}(Z)-\operatorname{dim}(Y)}(X).
$$
At least, this is true under some orientability assumptions (such that the Gysin maps exist in whatever cohomology theory you are using) which should be satisfied for complex subvarieties and integral cohomology. Then your statement follows by taking $a=1\in H^0(Y)$, since $[Y]=j_!(1)$.

It seems difficult to track down a simple reference for this fact. You could try some of the references given at Reference for push-pull formula in cohomology or Reference for base change of cohomology pull-push for clean intersections.. I seem to remember this being in Eldon Dyer's "Cohomology theories" book for generalized cohomology, but I can't track down a copy to check right now.

In algebraic geometry there are similar formulas in Chow groups, but I'm afraid I'm not an expert. The books I would be checking are Fulton's "Intersection Theory" and Fulton and MacPherson's "Categorical Framework for the Study of Singular Spaces".