Getting Error while merging code from my dev branch to my non-prod branch

I got a merge conflict while merging code from my dev branch to my non-prod branch.

What I was trying to do?

I created feature branch from dev (here dev and non-prod are identical.Both have same code repo).I did couple of commits each time and merged the code into dev branch with squash and with out squash. I successfully merged code from feature branch to dev branch without any issues (for all of these actions, I performed them through gitlab (UI) IDE).

But the moment I was trying to merge code from dev to non-prod, I ran into an issue i.e., merge conflict and gitlab giving me an error saying that try to resolve merge conflicts in your local machine and then push to non-prod branch. Then I jumped into my local machine and I did a git clone. I did check out from master to dev and check out from dev to non-prod. I did the git status command. It showed me unmerged file names. I used the git add command to make sure all files moved from unmerged file to files to be committed (staging area untracked files).And pushed to remote nonprod branch.Merge conflict was resolved.

Anyone have any ideas ? How to eliminate this kind of merge conflict issue in future and what exactly is happening here?