Canonical Systems with Rational Spectral Densities: Explicit Formulas and Applications