Unveiling the structural and electronic interplay in 3d and 4f/5d compounds at high-pressure