That’s true- not sure why, unless Pitney liked the movie, too and wrote the song afterward...
The song was written for the movie, but John Ford hated the song and did not put it in. It was then released as a single.
Liberty Valance - Song facts