The generalized Crewther relation and V-scheme: analytic $O(\alpha^4_s)$ results in QCD and QED