I believe in the rarest cases such similarities are a result of concious copying of adapting. Mostly the composer tries something out, then thinks “yeah, that sounds good.” And this click can either come from that the tune sounds familiar because the composer has already heard it somewhere else or because it is just a brillant idea. You never know.