# Why is mechanical waves faster in denser medium while EM waves slower?

Why is it that mechanical waves/longitudinal waves/sound travel faster in a denser/stiffer medium as in steel compared to say air, while EM waves/trasverse waves/light travels slower in a (optically) denser medium as in say glass?

I know that for mechanical waves,$$v \varpropto \sqrt{T}$$, where $T$ stands for Tension

and $$c \varpropto \sqrt{\frac{1}{\epsilon_0\mu_0}}$$

Any physical interpretation might be helpful.

EDIT: What I understand from this is that, since higher tension implies stronger intermolecular interaction, which leads to better conveyance of energy across the material which causes the waves to move faster. But this analogy doesn't fit at all for light waves. Why?

Mechanical waves are slower in a denser medium, provided that you keep the stiffness of the material the same. Steel is about $10^3$ times more dense than air, but its resistance to compression is millions of times greater.
If your T means temperature, then $v \propto \sqrt{T}$ is not for mechanical waves in general, it's for gases. At fixed pressure, a higher temperature gives a lower density, which causes a higher v.