This is answered in each of the creature's stat blocks.
For creature's such as oni, night hags, doppelgangers:
Its statistics are the same in each form.
Meaning that it keeps current statistics regardless of what specific form it takes and doesn't gain any new features.
Metallic dragons are a bit different:
In a new form , the dragon retains its alignment, hit points, Hit Dice, ability to speak, proficiencies, Legendary Resistance, lair actions, and Intelligence, Wisdom, and Charisma scores, as well as this action. Its statistics and capabilities are otherwise replaced by those of the new form, except any class features or legendary actions of that form.
A metallic dragon's stats are replaced by those of its new form (except those otherwise noted). You'll notice that the entry says class features, not racial features.
If the dragon's new form has a racial feature such as Innate Spellcasting or even Sunlight Sensitivity or the Genasi's elemental abilities then yes, they do gain those abilities. Note though that if the new form has the not-innnate-Spellcasting ability then the dragon isn't able to use it because it is considered a class feature.