About six months into learning guitar, I tried my hand at composing a song. Looked into some basic composing theory, picked a specific tempo, learned how to record and actually play the thing, and then two months later I "finished" the song, complete with lyrics and some non-standard flourishes. At the time I figured I was just putting some beginner chords together and testing out some basic theory.
Then, after I played it for a couple people, they rightly remarked that it sounds exactly like the rhythm progression for Mary Jane's Last Dance with different lyrics. And when I listened to the two back-to-back, they were entirely right. This worries me for a couple reasons.
Firstly, while Tom Petty never consciously entered my mind while I was composing, I'm a big fan of his and I'm familiar with MJLD. I never intended to plagiarize the song but I can't say I've never heard it, and it worries me that at any time I can accidentally tread on somebody else's work.
Secondly, supposing I had released my composition without noticing how similar it was and somebody wanted to take legal action against me for plagiarism, I don't know how I would defend myself. I can explain my way through the song and try to justify my choices of chords and tone but there's no way I can tell them why I just chose an amp setting that "sounded good."
Finally, work on the song has basically halted because running every flourish and idea through the lens of "is this REALLY my idea?" has thrown a kink in what's passing as my inventive process. There are only so many time signatures and so many chords I can use and it's not hard to find somewhere else somebody decided that an Em and a C chord sound good together.
My question is: is there some kind of rule of thumb or mindset I can follow to try and prevent this from happening again?