The SPHERE infrared survey for exoplanets (SHINE). III. The demographics of young giant exoplanets below 300 au with SPHERE