Here's why:
* Prepositional phrases consist of a preposition (in this case, "on") followed by its object (in this case, "shore").
* They act as modifiers, telling us more about the verb ("sang") or the noun ("songs").
* In this sentence, "on shore" tells us where the sailor sang the songs.