The multipopulation phenomenon in Galactic globular clusters: M4 and M22