Is it preferable to use custom code to create metaboxes instead of plugins (such as ACF) and if so why? [closed]

There is a right answer, write your own metabox code. Over the long run the amount of time you will need to “fight” the APIs of the plugins, to work around its bugs, and to maintain the plugin itself (upgrades and such) will cost you more than writting the code yourself.

If your site supposed to live only a short time maybe it is worth to use the plugins to get it going faster, but people usually underestimate how long a site will be alive once it gets going.