The necessary condition is not sufficient. In particular, it is impossible for $|\mathbb{Q}(a) : \mathbb{Q}| = |\mathbb{Q}(b) : \mathbb{Q}| = 5$ and $|\mathbb{Q}(a,b) : \mathbb{Q}| = 15$. This is because there is no group $G$ with subgroups $H$ and $K$ with $|G : H| = |G : K| = 5$ and $|G : H \cap K| = 15$. (So the argument works for arbitrary separable extensions.) I'm not happy with the proof I have of this, and I welcome cleaner arguments.

We may assume without loss of generality that $G$ is finite. Consider first the case in which $H$ and $K$ are conjugate in $G$. The action of $G$ on the cosets of $H$ gives a homomorphism from $G$ into $S_{5}$ with kernel contained in $H \cap K$, so we can assume that $G$ is a transitive subgroup of $S_{5}$. The only such groups of order a multiple of $15$ are $A_{5}$ and $S_{5}$ which are both doubly transitive and so the intersection of two point stabilizers has index $20$ in $G$, not $15$.

Now, suppose that $H$ and $K$ are not conjugate and consider the partition of $G$ into double cosets $HxK$ for $x \in G$. The double coset $HK$ has size $|H| |K|/|H \cap K| = \frac{3}{5} |G|$. The size of the double coset $|HxK| = |K| |H : H \cap xKx^{-1}| = |H| |K : K \cap x^{-1} Hx|$. Since $H \ne xKx^{-1}$, then $|HxK| = |K| |H : H \cap xKx^{-1}| \geq 2|K| = \frac{2}{5} |G|$. Thus, there are exactly two double cosets in the partition: $HK$ and $HxK$, with sizes $\frac{3}{5} |G|$ and $\frac{2}{5} |G|$.

It follows that $|K : K \cap x^{-1} Hx| = |H : H \cap xKx^{-1}| = 2$ and so $M_{1} = K \cap x^{-1} Hx$ is normal in both $K$ and $x^{-1} Hx$. Likewise $M_{2} = H \cap xKx^{-1}$ is normal in both $H$ and $xKx^{-1}$. Since $H$ and $K$ are maximal, it follows that $M_{1}$ and $M_{2}$ are both normal in $G$. Thus, $xM_{1}x^{-1} = x(K \cap x^{-1}Hx)x^{-1} = xKx^{-1} \cap H = M_{2}$, but since $M_{1}$ is normal in $G$, $M_{1} = M_{2}$. However, $M_{1} \subseteq H$ and $M_{2} \subseteq K$ and thus, $M_{1} = M_{2} = H \cap K$ actually has index $2$ in $H$ and $K$, which contradicts the assumption that $|G : H \cap K| = 15$.

EDIT: Here's a more general claim taking into account YCor's approach.

**Claim**: Suppose that $m = n$ is prime. Then $d = kn$ where

$\bullet$ $k = n$ or

$\bullet$ $k | n-1$ or

$\bullet$ if $n = \frac{p^{q}-1}{p-1}$ for primes $p$ and $q$, then $k = p^{q-1}$ or

$\bullet$ $n = 11$ and $k = 6$.

**Proof**: Letting $G$ act on the cosets of $H$ we get a homomorphism $\phi : G \to S_{n}$. Let $N = \ker \phi$. Then $NK$ is a subgroup of $G$ containing $K$. If $NK = G$ then $|G : N \cap K| = n^{2}$ but $N \subseteq H$ and this implies that $|G : H \cap K| = n$ or $n^{2}$.

In the case that $NK = K$, then we have that $N \subseteq K$. Replacing $G$ with $G/N$ we have that $G$ is a transitive subgroup of $S_{n}$. A theorem of Burnside from 1911 implies that either $G$ is solvable (and hence contained in the normalizer of a Sylow $p$-subgroup) or $G$ is doubly-transitive. If $G$ is solvable, then $G \cong (\mathbb{Z}/n\mathbb{Z}) \rtimes (\mathbb{Z}/k\mathbb{Z})$ where $k | n-1$ and $H$ and $K$ are conjugate in $G$ (since they are Hall $\pi$-subgroups). The orbits of a point stabilizer in such a group have size $1$ and $k$ and so $|H \cap K| = 1$ which has index $nk$.

In the case that $G$ is doubly-transitive, then for any minimal normal subgroup $N$ of $G$, $N$ is transitive and this implies that $C_{G}(N) = 1$. It follows that $G \subseteq {\rm Aut}(N)$. It therefore suffices to find the finite simple groups that are doubly-transitive. This determination follows from the classification of finite simple groups (and is given by Peter Cameron in "Finite Permutation Groups and Finite Simple Groups" published in the Bulletin of the London Mathematical Society in 1981; see the table on page 8).
The only such groups that can have prime degree are $A_{n}$, ${\rm PSL}_{q}(\mathbb{F}_{p})$ of degree $\frac{p^{q}-1}{p-1}$, ${\rm PSL}_{2}(\mathbb{F}_{11})$, $M_{11}$ and $M_{23}$. Moreover, if the subgroups $H$ and $K$ are conjugate the double transitivity implies that $|G : H \cap K| = n(n-1)$. Therefore, examples where this doesn't occur must arise from simple groups with more than one conjugacy class of subgroups of index $n$. This occurs only for ${\rm PSL}_{q}(\mathbb{F}_{p})$ with $q > 2$ and ${\rm PSL}_{2}(\mathbb{F}_{11})$.

In the case of ${\rm PSL}_{q}(\mathbb{F}_{p})$, one class of subgroups comes from the stabilizers of one-dimensional subspaces of $\mathbb{F}_{q}^{d}$ and the other class comes from stabilizers of codimension one subspaces. The stabilizer of a codimension one subspace has two orbits on the one-dimensional subspaces: one of size $\frac{p^{q-1} - 1}{p-1}$, and the other of size $p^{q-1}$. The former is a divisor of $n-1$.

Finally, in the case of ${\rm PSL}_{2}(\mathbb{F}_{11})$ there are two classes of subgroups of index $11$. If $H$ comes from the first class, the orbits of $K$ have sizes $5$ and $6$, and this gives rise to the possibility $m=n=11$ and $k = 6$. QED

notnecessary. $\endgroup$ – HeinrichD Oct 31 '17 at 13:34