The 16 digit card number has a different last four digits but the first twelve are the same. I presume that's what you mean by account number; it doesn't seem to have any bearing on the bank account number (although this is displayed on the card).
That's not always correct. Some banks will keep the same PAN (the industry name for the 16-digit card number) on new cards, others will change the last three or four digits, others still will change the seventh, eighth, and last digits.
How would the TVM know which cards are connected on a joint accout? I would expect it simply has a database of tickets, uniquely identified by the ticket reference and card number...
If the card has the same PAN and expiry date it would match. If it doesn't, it wouldn't. There are additional details on the chip and stripe called the PAN sequence number (this is equivalent to the issue number that used to be printed on all debit cards but nowadays has mostly been removed) which enables a distinction to be made between the two cards in point of sale use. You will see "PAN SEQ NO" on many card receipts.
The TVM would keep your old card, the Scotrail machines at Waverley seem to retain cards each week for some poor unsuspecting people, to make it worse for them they can't get the card out the machine!
Most TVMs do not have the capacity to retain cards. FSR is an exception. But I wonder if the cards haven't simply jammed.
With a new credit/debit card, only the 16 digit card number changes as the card is linked to your account.
Your 8 digit account number and 6 digit sort code do not change.
You can also use the same PIN number most of the time too.
HTH.
(Apologies for the slightly off topic post)
Again, the 16-digit PAN may not change.
Hardly any cards have the account number on them these days.
All the debit cards I have ever had in the UK have had my account number on them.