Reading the wikipedia article on STS-3xx, I noticed that the numbering does not seem consistent.
Space Shuttle contingency rescue missions were all numbered in the 300s with the exception of STS-400, as that was a special case.
STS-300 and -301 seem to have been numbered sequentially as the first contingency missions.
STS-300 (Atlantis) was planned for both STS-114 and STS-121 (both Discovery). This numbering also skipped 5 regular missions which ended up happening later, two of which were also by Discovery.
STS-317 and -318 seem to have been numbered after the mission their crews and orbiters were planned to fly. (If STS-117 had needed the contingency mission, a subset of the crew of STS-118 would have flown as STS-318 to rescue STS-117)
But after that the numbers seem to go a bit astray.
The orbiters assigned aren't always the same as the regular missions that share the last two digits too.
How were the numbers and orbiters of the contingency missions assigned?
Here is a mission designation table for STS-3xx flights, taken from Wikipedia
+---------------------+---------------------+
| Flight | Rescue Flight |
+---------------------+---------------------+
| STS-114 (Discovery) | STS-300 (Atlantis) |
| STS-121 (Discovery) | STS-300 (Atlantis) |
| STS-115 (Atlantis) | STS-301 (Discovery) |
| STS-116 (Discovery) | STS-317 (Atlantis) |
| STS-117 (Atlantis) | STS-318 (Endeavour) |
| STS-118 (Endeavour) | STS-322 (Discovery) |
| STS-120 (Discovery) | STS-320 (Atlantis) |
| STS-122 (Atlantis) | STS-323 (Discovery) |
| STS-123 (Endeavour) | STS-324 (Discovery) |
| STS-124 (Discovery) | STS-326 (Endeavour) |
| STS-125 (Atlantis) | STS-400 (Endeavour) |
| STS-134 (Endeavour) | STS-335 (Atlantis) |
+---------------------+---------------------+