The sequence can be changed and optimized for several reasons:
* There are untranslated regions (UTR) that could influence the regulation or stability of the mRNA.
* Since most amino acids are encoded by more than codon, the coding region for the spike protein can be codon optimized. Altering the codon composition can improve protein expression.
* Likewise, enrichment of G:C content in the mRNA sequence might result in increased mRNA and expressed protein yields in vivo.
See https://www.nature.com/articles/nrd.2017.243#Sec4 for more information.
Edit:
> Do both of these sequences express the same protein?
In this case both vaccines express exactly the same amino acid sequence.
> Or is there a "close enough!" thing in the immune system, where it can be a little different and still be targeted by the immune system?
It depends on how different the sequence is. For instance, if it is a little different the immune response should be very similar because, for example, the three-dimensional conformation of the spike protein chain should remain very similar as well. This is why the vaccines can be effective against several SARS-CoV2 variants.