Keir Starmer has flagged the British government is preparing to legislate to curb functions that keep young people hooked on social media.