in songwriting and recording there are guidelines that separate the two. They still often end up in court for final determination, but when everyone started sampling and the outcome of the 'he's so fine' case set precedents that make it easier to follow.
You can't copyright a chord progression but melody and lyrics can be copyrighted. You also have free reign with song titles -- those can't be copyrighted either.
If a song has made money then it becomes a legal target for others to try and get their hands on a slice of the pie. If your song that 'borrows' from another song makes no money then no-one gives a toss.