I am new to 5E. Something I am wondering about is if I declare that this turn I am going to move X feet and attack target A and then move X feet and attack target B, what happens if my target moves or dies before it is my turn? Do I do nothing? Do I move but not attack and lose all or some of my attacks?
You don't declare your actions beforehand; you just take them.
Chapter 9 of the PHB/basic rules describes how actions in combat work.
The "Combat Step-by-Step" sidebar in the "The Order of Combat" section lists how combat proceeds:
- Determine surprise. The DM determines whether anyone involved in the combat encounter is surprised.
- Establish positions. The DM decides where all the characters and monsters are located. Given the adventurers' marching order or their stated positions in the room or other location, the DM figures out where the adversaries are--how far away and in what direction.
- Roll initiative. Everyone involved in the combat encounter rolls initiative, determining the order of combatants' turns.
- Take turns. Each participant in the battle takes a turn in initiative order.
- Begin the next round. When everyone involved in the combat has had a turn, the round ends. Repeat step 4 until the fighting stops.
As you can see, it doesn't state anywhere in this macro view that you declare your actions before taking your turn.
Looking at the "Your Turn" section, we can see the kinds of things you can do on your turn:
On your turn, you can move a distance up to your speed and take one action. You decide whether to move first or take your action first. Your speed--sometimes called your walking speed--is noted on your character sheet.
The most common actions you can take are described in the Actions in Combat section. Many class features and other abilities provide additional options for your action.
The Movement and Position section gives the rules for your move.
You can forgo moving, taking an action, or doing anything at all on your turn. If you can't decide what to do on your turn, consider taking the Dodge or Ready action, as described in "Actions in Combat."
The section goes on to describe bonus actions:
Various class features, spells, and other abilities let you take an additional action on your turn called a bonus action. [...] You can take a bonus action only when a special ability, spell, or other feature of the game states that you can do something as a bonus action. You otherwise don't have a bonus action to take.
And other activity on your turn:
You can communicate however you are able, through brief utterances and gestures, as you take your turn.
You can also interact with one object or feature of the environment for free, during either your move or your action. For example, you could open a door during your move as you stride toward a foe, or you could draw your weapon as part of the same action you use to attack.
If you want to interact with a second object, you need to use your action. Some magic items and other special objects always require an action to use, as stated in their descriptions.
And even reactions:
Certain special abilities, spells, and situations allow you to take a special action called a reaction. A reaction is an instant response to a trigger of some kind, which can occur on your turn or on someone else's. The opportunity attack, described later in this section, is the most common type of reaction.
...But as you can see, nowhere in any of these rules does it state that you must declare the action you intend to take at any point; it only says that you take them (some at any time, some when a certain condition is met or when a feature/spell lets you take them).
Later in the "Movement and Position" section, it tells you how movement works:
On your turn, you can move a distance up to your speed. You can use as much or as little of your speed as you like on your turn, following the rules here.
You can break up your movement on your turn, using some of your speed before and after your action. For example, if you have a speed of 30 feet, you can move 10 feet, take your action, and then move 20 feet.
You can even move between attacks:
If you take an action that includes more than one weapon attack, you can break up your movement even further by moving between those attacks. For example, a fighter who can make two attacks with the Extra Attack feature and who has a speed of 25 feet could move 10 feet, make an attack, move 15 feet, and then attack again.
Again, there's no mention of declaring your actions.
As you can see, there's nothing in the rules that requires you to declare your actions beforehand - you simply do the things you want to do on your turn, if you have the movement, action, or bonus action (or whatever other resource it takes) available to do so.
D&D combat is sequential, with no action-declaration phase at the beginning. Your turn can also be interrupted by someone’s reaction. Such an interruption could, among other things, incapacitate you, meaning your intention to take a certain action was never fulfilled.
There is, indeed, tons of flexibility in how certain things can be ordered in combat. But if one thing is conditional on another, they must happen in order, for intent has no weight in the combat rules, since you could be interrupted at any moment and incapacitated.
D&D combat doesn't have an action-declaration phase. Things happen in order, and you can be interrupted at any moment by a reaction, trap, or the like. You can say, "I plan to take the Attack action," but that has no rules relevance until you're actually taking the action.
In D&D, the way you take an action in combat is to actually take the action. There is no action-declaration phase. Flurry of Blows happens after the Attack action, which means the action itself, not a declaration that you will take the action.
If this is something you have seen it may be a house rule
In case you aren't aware, a house rule is when a DM adds a new rule into the game that isn't specifically written in the books.
One house rule I have seen is from people wanting to make more of the initiative order. They roll initiative, then the lowest in the order declares an action, followed by everyone else in the order. Once all actions are called the round is played out.
I think the idea around this is to allow those who win the initiative a little strategic advantage. For example if I know you are going to cast hold person but are lower on the initiative order I can hold my attack for the auto-crit, or attack someone else and leave that target entirely to you.
The downside is that if you say you are casting hold person and I ignore it then you could end up effectively losing your turn.
So check with your DM if a house rule is in play
With the great answer of V2Blast, you won't need any additional info on how turns work. However, there is an option to Ready an action. The exact details of this are explained in this answer: How does the Ready action work?.
In short, the Ready action will allow you to declare a trigger: "When someone does X" and an action or movement: "Then I will do Y".
This allows for some flexibility in combat. Be aware, however that the Ready action uses your action to declare the trigger and reaction, but you will still have to use your reaction to act upon the trigger.
As for the trigger, if it doesn't happen it simply does nothing.
Me: I ready an attack against this goblin, when I recieve a buff from an ally.
Ally: I cast Bless on SlimeBolt.
Me: I use my reaction to attack the goblin.
This would be the normal course of action when the trigger of the Ready action occurs.
Me: I ready an attack against this goblin, when I recieve a buff from an ally.
Ally: I attack that goblin.
Ally 2: I cast Bless on SlimeBolt
In this case, I cannot use my reaction to attack the goblin, since it is no longer there. In effect this will skip my turn in combat.
You do not declare your actions
Under the usual rules of DnD 5e, you have no obligation to decide the actions to take during your turn in advance. Any declarations you make are non-binding unless you've specifically agreed otherwise as a group (which I recommend against, since wasting turns slows down play and can quickly become frustrating). You are therefore free to use your action for anything you want, regardless of your original intended target being killed or not.
For further information, you can look up the combat rules in the free Basic Rules of DnD Beyond.