I think your issue may be that you were changing targets but not confirming it. When you first perform an action on something, it gets the big arrow over it and is your "main" target. If you change targets with the D-pad, it's only temporary and will return to your main target after any action. However, if you push X on your new target before performing an action, that target will become your new main.

For example, if I want to focus on healing a tank I target them, hit X, and do some heals. If a random party member takes some damage, I target them, don't hit X, and after i heal them my target returns to the tank. If my tank is fine and I want to nuke a bit, I target the enemy and hit X to change them to my main target.