I don’t get plagiarism. McCartney was exactly afraid of this and played it for everyone he could to make sure they hadn’t heard it.
I wrote a song once and played it for a couple of members of our worship group. I asked it they thought it might have already been written.
They both were able to name that tune.
Almost all simple melodies and chord progressions have already been written.