$\DeclareMathOperator\rank{rank}$Let $G$ be a compact connected Lie group and $H$, $K$ be two closed connected subgroups. By Mikhail Borovoi's answer to In a compact lie group, can two closed connected subgroups generate a non-closed subgroup?, $L=\langle K, H\rangle$ (the subgroup generated by $K$, $H$) is a closed connected subgroup of $G$ (hence a Lie subgroup). Now assume additionally that $$r=\rank(H\cap K)=\rank H=\rank K.$$ My question is if we can conclude that $$\rank L=r.$$

No. A simple example is to let $G = \mathrm{SO}(6)$, which has rank $3$. Let $v_1$ and $v_2$ be unit orthogonal vectors in $\mathbb{R}^6$ and let $H_1\simeq \mathrm{SO}(5)\subset G$ be the stabilizer of $v_1$ and let $H_2\simeq \mathrm{SO}(5)\subset G$ be the stabilizer of $v_2$. Then $H_1\cap H_2\simeq\mathrm{SO}(4)$ which has rank $2$, as do $H_1$ and $H_2$. However, $H_1$ and $H_2$ together generate $L = G$, which has rank $3$.

(Actually, come to think of it, one could do the same construction with $G = \mathrm{SO}(4)$ and get an even lower dimensional example in which the rank of $L$ is greater than that of $H_1$ and $H_2$.)