We need to make use of the condition that $A$ and $B$ are real symmetric matrices, otherwise the assertion that $AB=0$ may be false. For example, let $A=I$ and $N$ be the nilpotent matrix $\pmatrix{0&1\\ 0&0}$. The determinantal equality is then satisfied when $B=N$ (so that $A$ and $B$ are real but $B$ is not symmetric) or when
$B=\pmatrix{2&1\\ 2i&1}N\pmatrix{2&1\\ 2i&1}^{-1}=\pmatrix{1-i&1+i\\ 1+i&i-1}$
(so that $A$ and $B$ are symmetric but $B$ is not real), but $AB=B\ne0$.
Anyway, suppose $A$ and $B$ are real symmetric. The determinantal condition implies that $\det(yI-A)\det(yI-B)=y^n\det(yI-A-B)$ for every real number $y$. Hence $\pmatrix{A\\ &B}$ and $\pmatrix{A+B\\ &0}$ have the same characteristic polynomial, and they must be similar because they are real symmetric. In particular,
$$
d+s:=\operatorname{rank}(A)+\operatorname{rank}(B)=\operatorname{rank}(A+B)\le n.
$$
Let $A=UDU^T$ and $B=VSV^T$ where each of $U\in M_{n,d}(\mathbb R)$ and $V\in M_{n,s}(\mathbb R)$ has orthonormal columns and $D\in M_{d,d}(\mathbb R),\,S\in M_{s,s}(\mathbb R)$ are invertible diagonal matrices containing the nonzero eigenvalues of $A$ and $B$ respectively. From the similarity between
$$
\pmatrix{A\\ &B}\quad\text{and}\quad\pmatrix{A+B\\ &0},
$$
we infer the similarity between
$$
\pmatrix{D\\ &S\\ &&0_{(n-d-s)\times(n-d-s)}}
\quad\text{and}\quad
A+B=\pmatrix{U&V}\pmatrix{D\\ &S}\pmatrix{U^T\\ V^T}.
$$
In turn,
$$
\pmatrix{D\\ &S}
\quad\text{and}\quad
\pmatrix{U^T\\ V^T}\pmatrix{U&V}\pmatrix{D\\ &S}
$$
have the same characteristic polynomial. Therefore
$$
\det\pmatrix{I_d&U^TV\\ V^TU&I_s}
=\det\left(\pmatrix{U^T\\ V^T}\pmatrix{U&V}\right)
=1
$$
and by Hadamard’s inequality for positive definite matrices (i.e., $\det P\le\prod_i p_{ii}$ whenever $P$ is PD, and equality holds iff $P$ is diagonal), we must have $U^TV=0$. Hence $AB=UDU^TVSV^T=0$.