The same mathematical formalism of the wave equation can be used to describe anelastic and electromagnetic wave propagation. In this work, we obtain the mathematical analogy for the reflection/refraction (transmission) problem of two layers, considering the presence of anisotropy and attenuation -- viscosity in the viscoelastic case and resistivity in the electromagnetic case. The analogy is illustrated for SH (shear-horizontally polarised) and TM (transverse-magnetic) waves. In particular, we illustrate examples related to the magnetotelluric method applied to geothermal systems and consider the effects of anisotropy. The solution is tested with the classical solution for stratified isotropic media.