There’s a funny story about the song “Her Majesty” on Abbey Road. And it gives you an idea of how the Beatles worked in the studio. Originally it was going to be part of the medley of songs on side B. But at the last second Paul decided that it really didn’t fit, so he cut it out of the master tape (that’s why you hear the loud chord from the previous song at the beginning, and the quick cut at the end).
So then, when one of the assistant engineers was going through all the master tapes and putting all the songs together in their running order so they could press up the record, he noticed the little snippet of the “Her Majesty” song that Paul had cut out. All the engineers were under strict orders to NEVER throw out anything the Beatles recorded, even out-takes, because they could turn out to be valuable. So he put the snippet at the very end of the master tape, after the final fade-out, just so it wouldn’t get lost in the shuffle.
Later, when Paul was listening to the master tape of the Abbey Road album one last time before it was pressed up, he gets to the end of the album and he kind of relaxes because the whole thing is finally over and it sounds great. And then after a silent pause, the little snippet of “Her Majesty” comes on out of nowhere. Which jolted him because he wasn’t expecting it. But he decided he liked it. It added a nice little surprise to the end of record, this little reprise. And it took some of the pretentiousness out of the big ending, “the love you make is the love you take” bit. And added a nice touch of lightness and whimsy, and was the perfect way to end the Beatles recording career. So he left it in there just like it was, just like a happy accident.