Comparison
Here is a quick and dirty summary of the main differences between these spells.
Polymorph True Polymorph Shapechange
Level 4 9 9
Cost Nil Nil 1,500gp
Range 60 feet 30 feet Self
Limits Beasts only None Must have been seen
No constructs or undead
Statistics Creature’s Creature’s Creature’s STR, DEX, CON
Your INT, CHA, WIS
Proficiencies Not mentioned Not mentioned Yours but may use creature’s bonus if better
(creature’s?) (creature’s?)
Class, Race Creature’s Creature’s Yours
Abilities (Subject to capability)
Equipment Merged Merged Falls off OR
Merged OR
Worn
Change form No No 1 Action
Source Information
Of specific relevance to the question are these words that each spell uses:
Polymorph
The new form
can be any beast whose challenge rating is equal to or
less than the target’s (or the target’s level, if it doesn't
have a challenge rating). The target’s game statistics,
including mental ability scores, are replaced by the
statistics of the chosen beast. It retains its alignment
and personality.
...
The creature is limited in the actions it can perform by
the nature of its new form, and it can’t speak, cast spells,
or take any other action that requires hands or speech.
Shapechange
You transform into an average example of that creature, one
without any class levels or the Spellcasting trait.
Your game statistics are replaced by the statistics
of the chosen creature, though you retain your
alignment and Intelligence, Wisdom, and Charisma
scores. You also retain all of your skill and saving
throw proficiencies, in addition to gaining those of the
creature. If the creature has the same proficiency as you
and the bonus listed in its statistics is higher than yours,
use the creature’s bonus in place of yours. You can’t use
any legendary actions or lair actions of the new form.
...
You retain the benefit of any features from your class,
race, or other source and can use them, provided that
your new form is physically capable of doing so. You
can’t use any special senses you have (for example,
darkvision) unless your new form also has that sense.
You can only speak if the creature can normally speak.
True Polymorph
The target’s game statistics, including mental ability scores, are replaced by the statistics of the new form. It retains its alignment and personality.
...
The creature is limited in the actions it can perform by
the nature of its new form, and it can’t speak, cast spells,
or take any other action that requires hands or speech
unless its new form is capable of such actions.
Also relevant is this quote from the Monster Manual (p.6)
A monster's statistics, sometimes referred to as its stat
block, provide the essential information that you need
to run the monster.
And (p.11)
INNATE SPELLCASTING
A monster with the innate ability to cast spells has
the Innate Spellcasting special trait. Unless noted
otherwise, an innate spell of 1st level or higher is
always cast at its lowest possible level and can't be cast
at a higher level. If a monster has a cantrip where its
level matters and no level is given, use the monster's
challenge rating.
An innate spell can have special rules or restrictions.
For example, a drow mage can innately cast the levitate
spell, but the spell has a "self only" restriction, which
means that the spell affects only the drow mage.
A monster's innate spells can't be swapped out with
other spells. If a monster's innate spells don't require
attack rolls, no attack bonus is given for them.
SPELLCASTING
A monster with the Spellcasting class feature has a
spellcaster level and spell slots, which it uses to cast
its spells of 1st level and higher (as explained in the
Player's Handbook). The spellcaster level is also used
for any cantrips included in the feature.
The monster has a list of spells known or prepared
from a particular class. The list might also include
spells from a feature in that class, such as the Divine
Domain feature of the cleric or the Druid Circle feature
of the druid.
A monster can cast a spell from its list at a higher level
if it has the spell slot to do so. For example, a drow mage
with the 3rd-level lightning bolt spell can cast it as a
5th-level spell by using one of its 5th-level spell slots.
You can change the spells that a monster knows or
has prepared, replacing any spell on a monster's spell
list with a different spell of the same level and from
the same class list. If you do so, you might cause the
monster to be a greater or lesser threat than suggested
by its challenge rating.
The "Vibe"
It retains its alignment and personality.
which all the spells use suggest that the original being is inside the new creature in some way. Its who they were just in a different shape.
Shapechange has the vibe that not only your personality but your knowledge and skill is still intact; you are simply wearing the new creature - this feels similar to the druid's shapechange ability.
Polymorph and True Polymorph on the other hand have the vibe that they have become the creature, not just physically but mentally as well. There is a suggestion that they remember who they were in True Polymorph but this is by extrapolating from the fact that if you turn them into an object, "the creature has no memory of time spent in this form".
Spellcasting
Shapechange is the easiest, that's you in there; provided the shape you have chosen can do so, you can cast the spells you have memorised. You have the slots used and unused that you had before and if you use them while Shapechanged they are gone when you revert.
The others use:
The creature is limited in the actions it can perform by
the nature of its new form, and it can’t speak, cast spells,
or take any other action that requires hands or speech
unless its new form is capable of such actions.
While somewhat ambiguous the only sensible way of parsing the sentence is that if it has hands or speech then it can cast spells that require S/M & V components respectively.
So whose spells are they that it can theoretically cast?
Well it has "the creature's statistics", unless polymorphed into itself (which is a huge waste of a spell) they are not the spells of the original creature; they must be the spells of the new creature.
It is up to the DM to decide if you can choose to polymorph into a "Drow Mage" or if you are limited to just "Drow" for example. If this is allowed then you get access to the "Innate Spellcasting" and "Spellcasting" traits that are an integral part of the "Drow Mage".
It is also up to your DM if you can polymorph into a specific person - "my friend Sally, the 18th level Cleric" or if you are limited to what is in the Monster Manual - "Priest".