Rankin-Cohen algebras and $\mathfrak{sl}_2$-algebras