Yes, they can.
Choosing a target is part of making an attack, not part of taking your turn or taking the attack action (and in this case it's two separate actions, one action and one bonus action, making the separation even larger). Making an attack has three phases:
Whether you're striking with a melee weapon, firing a weapon at range, or making an attack roll as part of a spell, an attack has a simple structure.
Choose a target. Pick a target within your attack's range: a creature, an object, or a location.
Determine modifiers. The DM determines whether the target has cover and whether you have advantage or disadvantage against the target. In addition, spells, special abilities, and other effects can apply penalties or bonuses to your attack roll.
Resolve the attack. You make the attack roll. On a hit, you roll damage, unless the particular attack has rules that specify otherwise. Some attacks cause special effects in addition to or instead of damage.
As attacks are not simultaneous (as evidenced by being able to move between attacks) and there is no rule that requires a pre-declaration of attack targets — targeting is part of the individual attacks, not an overall action — nor is there any rule that requires all attacks in a turn target the same enemy, you are able to decide your target with each attack based on the outcome of prior attacks.