How to prevent additional code in functions.php to be removed once there is an update?

There isn’t a way. You need to create a child theme or a plugin and put the functions there.

Note that there’s nothing special about child themes. The point is to put the code into something that somebody else isn’t going to update. So third party child themes aren’t safe either.