An ACF gallery field holds an array of attachment IDs. My guess is that whatever you are using to insert the values is creating multiple entries in the post meta table instead of a single array entry. You will need to alter it to save the value the way ACF needs it in the DB. I don’t know how to do that.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users