Move your entire block of code that starts with
if (isset($_POST['update_social_media'])) {
to before you get the field, updating happens before display. Then if the value has been updated instead of getting the value you can just skip that and us the submitted value. Then you only need to get the value it it is not present in $_POST.