You may think a seed phrase is a bunch of randomly chosen words.
It is! But it also, isn't.
It was generated using a specific standard known as the BIP39 standard, the method in which your wallet took all the needed information to recover your wallet and made it into a 12-24 word phrase.
In the BIP39 standard, the last word is unique (what does that even mean?).
The last word of BIP39 seed phrase is called a checksum (well “part” of it to be accurate).
In general, the purpose of a checksum is to detect errors in a set of data.
In the case of a seed phrase, the purpose of the last word is ensuring your seed phrase is following the "rules" and structure described in the BIP39 standard. It is calculated from the initial data used to generate your seed.
If you're wondering why the seed you made up worked in a wallet you've used before, per the BIP39 documentation, "Although using a mnemonic not generated by the algorithm described in "Generating the mnemonic" section is possible, this is not advised and software must compute a checksum for the mnemonic sentence using a wordlist and issue a warning if it is invalid." This means that a wallet will not outright reject an invalid seed, rather it will accept it and should only give you a warning (which is up to the developer's discretion).
Thus, you cannot chose any 12-24 words and have a valid seed phrase due to the last word acting as the checksum. The last word is partially calculated using the data stored in the previous words.
The last word of a 24 word seed phrase can be any 8 potential words based on the previous 23.
The last word of a 12 word seed phrase can be any 128 potential words based on the previous 11.
It's important to know how a seed phrase is generated to understand how the the last word is calculated: See How a Seed Phrase is Created.
Also, you'll need some computational help to determine the potential last words from the previous words. If you're interested in how to do that, see: Find the Last Word in a Seed Phrase.