You’re running afoul of some major name conflicts here: there are multiple different things that are called “dodge.”
So, three instances of the word “dodge” that are not actually the same:
Dodge bonuses. This is just a type of bonus, almost-always to AC. For clarity, the rest of the answer will refer to these as “dodge-type bonuses.” Dodge-type bonuses stack with other dodge-type bonuses (unlike most types of bonuses), and you lose dodge-type bonuses to AC any time you would lose your Dexterity bonus to AC.
The Dodge feat. This is a feat that gives a dodge-type bonus to AC, but only against one chosen target.
The Uncanny Dodge class feature. This is a class feature that allows one to keep one’s Dexterity bonus to AC in more situations. Since you don’t lose your Dexterity bonus to AC, you also don’t lose any dodge-type bonuses to AC that you may have (since you usually lose those when you lose your Dexterity bonus to AC). However, the Uncanny Dodge class feature itself does not grant any bonus, dodge-type or otherwise, it just affects when you lose any bonuses you may or may not already have.
Note that the restriction of applying only to one target is a facet of the Dodge feat; it does not apply to any other source of dodge-type bonuses, nor does it have anything at all to do with Uncanny Dodge.
So, for example, the dwarven dodge-type bonus to AC against giants applies to any and all giants, all at once. You do not have to pick one. If a dwarf has the Dodge feat, he can apply the Dodge feat’s dodge-type bonus against the attacks of any one creature. If that creature is a giant, the dwarf gets to stack his racial bonus alongside the bonus from the feat, for a total of +5. His dodge-type bonus against other giants remains the same +4.
If he does not have Uncanny Dodge, he loses all of these dodge-type bonuses when caught flat-footed or attacked by an invisible attacker, since he loses his Dexterity bonus to AC and dodge-type bonuses are tied the to Dexterity bonus. However, if he does have Uncanny Dodge, then he gets to keep these dodge-type bonuses in this case, because Uncanny Dodge lets him keep his Dexterity bonus.
So, for your example:
Dex-16 4th-level dwarf rogue with leather armor: basic armored AC of 15. Note that dwarves are Medium creatures, and therefore have a size bonus of +0, not +1. (Only Small creatures get a +1 size bonus to AC.)
Touch attacks ignore the leather armor, so against those his AC is 13.
Since he is a rogue with Uncanny Dodge, being flat-footed does not
cost him his Dexterity bonus to AC, so his flat-footed AC is the same
as his regular AC. It is still possible to lose one’s Dexterity bonus
to AC with Uncanny Dodge, however (balancing is a big one); if that
happens, his AC is 12.
He gains a +4 dodge-type bonus against any and all giants, so that includes our two hill giants. For this fight, against only giants, his AC is 19. Uncanny Dodge means he keeps those dodge bonuses even if caught flat-footed or the hill giants are invisible (but not if he is balancing or otherwise does lose Dexterity to AC; then his AC is back down to 12 since it takes out the dodge-type bonuses as well as the Dexterity bonus).
He may designate one of the hill giants for his Dodge feat. His AC against that hill giant only improves to 20. Against the other hill giant, his AC remains 19.
Flanking doesn’t affect AC. If the hill giants are flanking him, they get a +2 bonus to their attacks. If they are also rogues, they would also get to add their Sneak Attack damage to their attacks, as appropriate.
There are no monsters or effects in 5e which drain levels/cause loss of experience.
Most of the monsters we'd have once associated with XP drain now have attacks which will drop one's maximum HP. These include the demilich, specter, *cubus, wight, and wraith. A shadow has an attack which drops one's strength score.
Even the Deck of Many Things, one of the game-break-iest things in D&D, won't cause one to lose a level. The Fool, when drawn, will cost 10,000 XP. But "if losing that much XP would cause you to lose a level, you instead lose an amount that leaves you with just enough XP to keep your level." That is, you may lose only one XP if you'd just crossed a level-threshold. (DMG p.164, with thanks to @xanderh for the pointer.)
If you chose to incorporate level/XP loss, you're into homebrew territory.
Best Answer
You cannot benefit from the racial feat if your race changes
Page 165 of the PHB says:
The racial feats in XGtE all have a prerequisite that specifies the race that can take them. For example, Bountiful Luck has the Halfling prerequisite.
Therefore, if you are no longer a halfling because of reincarnation, then you cannot use the benefits of the feat.
But you will regain the use of the feat if your prerequisite race is restored
As the quote from the PHB says, you can regain the feat's benefits if you regain the prerequisite. So, if something turns you back into whatever race the racial feat requires, you regain the benefit of the feat.
In your example, if you are a halfling, die, and are reincarnated as a dwarf, you would be unable to benefit from the Bountiful Luck feat. But if you then died again and were reincarnated back into a halfling, you would regain the use of Bountiful Luck because you are a halfling again.