I believe it's, generally, a matter of style—but it may also be a question of "rules" on the part of regional mapmakers or specific cities.
For example, Open Street Map has a discussion that claims St is always used in the UK. To quote a passage from the Cambridge Guide to English Usage used in that discussion:
When saints' names are written into those of institutions, the
shortened form St(.) is always used... Geographical names which honor
a saint are likewise written with St(.): St Gotthard Pass, St Kilda,
St Moritz, St Petersburg. Abbreviated forms like these are used in the
gazetteers of world atlases published by The Times and Oxford, among
others, and they reflect common usage... Use of full stop/period: The
shortened form St is normally left unstopped by British writers and
editors, because (a) it's a contraction rather than an abbreviation,
and (b) it contains a lower case letter.
(Note that in North America, the style is to use a terminal period after the shortened name. It's also interesting to note that the passage seems to be talking about at least some cities outside the UK—and, therefore, could only be considered an "authoritative" source for how UK-based publications reference them, not necessarily what their names actually are.)
However, according to the official website of the city of Saint John, New Brunswick, Canada:
The “Saint” part of the city of Saint John is traditionally not
abbreviated in common spelling in order to differentiate it from St.
John’s, Newfoundland and Labrador, another city in Canada whose name
usually uses this abbreviation.
This seems to imply that, in Canada anyway, St. actually is an abbreviation of a longer legal name.
I suppose you could look at the articles of incorporation for the towns or cities in question if you want to see what their legal names were at the time they were founded. However, even that may not necessarily be conclusive.